From f1cdd6a978c86b600670b79304be95b52ce0a511 Mon Sep 17 00:00:00 2001
From: Octavia Togami
Date: Sun, 7 Apr 2024 01:54:49 -0700
Subject: [PATCH 01/21] Update for Java 21
- Fix some new warnings
- Removed sponge from build, as it simply isn't maintained well
currently. May be removed entirely in the future
- Remove 1.18 support from Bukkit as it breaks under 21 for some reason
- Fix a bug in `ForwardSeekableInputStream`
---
buildSrc/build.gradle.kts | 20 +++++++++++++++----
buildSrc/src/main/kotlin/AdapterConfig.kt | 7 ++++++-
buildSrc/src/main/kotlin/CommonConfig.kt | 2 +-
buildSrc/src/main/kotlin/CommonJavaConfig.kt | 3 ++-
buildSrc/src/main/kotlin/PlatformConfig.kt | 2 +-
gradle.properties | 4 ++--
settings.gradle.kts | 4 ++--
verification/build.gradle.kts | 2 +-
worldedit-core/build.gradle.kts | 2 +-
worldedit-core/doctools/build.gradle.kts | 8 +-------
.../sk89q/worldedit/WorldEditManifest.java | 4 ++--
.../sk89q/worldedit/entity/BaseEntity.java | 3 +++
.../extent/validation/BlockChangeLimiter.java | 1 +
.../worldedit/regions/Polygonal2DRegion.java | 10 +++-------
.../util/io/ForwardSeekableInputStream.java | 3 ++-
.../sk89q/worldedit/util/net/HttpRequest.java | 9 ++-------
.../worldedit/util/paste/EngineHubPaste.java | 3 ++-
.../util/task/FutureForwardingTask.java | 13 ++++++------
.../util/translation/TranslationManager.java | 2 +-
.../worldedit/world/block/BlockType.java | 7 +++++++
.../worldedit/world/chunk/AnvilChunk13.java | 2 +-
.../sk89q/worldedit/world/item/ItemType.java | 4 +++-
worldedit-fabric/build.gradle.kts | 2 +-
worldedit-forge/build.gradle.kts | 2 +-
.../worldedit/forge/ForgeResourceLoader.java | 5 +++--
worldedit-sponge/build.gradle.kts | 2 +-
26 files changed, 73 insertions(+), 53 deletions(-)
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
index 095eca217c..c4ff0808fe 100644
--- a/buildSrc/build.gradle.kts
+++ b/buildSrc/build.gradle.kts
@@ -46,16 +46,28 @@ val mixinVersion: String = properties.getProperty("mixin.version")
dependencies {
implementation(gradleApi())
implementation("gradle.plugin.org.cadixdev.gradle:licenser:0.6.1")
- implementation("org.ajoberstar.grgit:grgit-gradle:5.2.1")
- implementation("me.champeau.gradle:japicmp-gradle-plugin:0.4.0")
+ implementation("org.ajoberstar.grgit:grgit-gradle:5.2.2")
+ implementation("me.champeau.gradle:japicmp-gradle-plugin:0.4.2")
implementation("com.github.johnrengelman:shadow:8.1.1")
- implementation("org.jfrog.buildinfo:build-info-extractor-gradle:5.1.14")
+ implementation("org.jfrog.buildinfo:build-info-extractor-gradle:5.2.0")
implementation("org.spongepowered:spongegradle-plugin-development:2.2.0")
implementation("org.spongepowered:vanillagradle:0.2.1-20231105.223944-69")
implementation("net.minecraftforge.gradle:ForgeGradle:6.0.21")
implementation("net.fabricmc:fabric-loom:$loomVersion")
implementation("net.fabricmc:sponge-mixin:$mixinVersion")
implementation("org.enginehub.gradle:gradle-codecov-plugin:0.2.0")
- implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.5.11")
+ implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.5.13")
implementation("org.spongepowered:mixingradle:0.7.38")
+ constraints {
+ val asmVersion = "[9.7,)"
+ implementation("org.ow2.asm:asm:$asmVersion") {
+ because("Need Java 21 support in shadow")
+ }
+ implementation("org.ow2.asm:asm-commons:$asmVersion") {
+ because("Need Java 21 support in shadow")
+ }
+ implementation("org.vafer:jdependency:[2.10,)") {
+ because("Need Java 21 support in shadow")
+ }
+ }
}
diff --git a/buildSrc/src/main/kotlin/AdapterConfig.kt b/buildSrc/src/main/kotlin/AdapterConfig.kt
index 04b30cbc7e..c940cb51d4 100644
--- a/buildSrc/src/main/kotlin/AdapterConfig.kt
+++ b/buildSrc/src/main/kotlin/AdapterConfig.kt
@@ -4,7 +4,7 @@ import org.gradle.kotlin.dsl.dependencies
// For specific version pinning, see
// https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
-fun Project.applyPaperweightAdapterConfiguration(javaRelease: Int = 17) {
+fun Project.applyPaperweightAdapterConfiguration(javaRelease: Int = 21) {
applyCommonConfiguration()
apply(plugin = "java-library")
applyCommonJavaConfiguration(
@@ -16,6 +16,11 @@ fun Project.applyPaperweightAdapterConfiguration(javaRelease: Int = 17) {
dependencies {
"implementation"(project(":worldedit-bukkit"))
+ constraints {
+ "remapper"("net.fabricmc:tiny-remapper:[0.8.11,)") {
+ because("Need remapper to support Java 21")
+ }
+ }
}
tasks.named("assemble") {
diff --git a/buildSrc/src/main/kotlin/CommonConfig.kt b/buildSrc/src/main/kotlin/CommonConfig.kt
index ba0f6bde87..e8bd844bbb 100644
--- a/buildSrc/src/main/kotlin/CommonConfig.kt
+++ b/buildSrc/src/main/kotlin/CommonConfig.kt
@@ -35,7 +35,7 @@ fun Project.applyCommonConfiguration() {
plugins.withId("java") {
the().toolchain {
- languageVersion.set(JavaLanguageVersion.of(17))
+ languageVersion.set(JavaLanguageVersion.of(21))
}
}
diff --git a/buildSrc/src/main/kotlin/CommonJavaConfig.kt b/buildSrc/src/main/kotlin/CommonJavaConfig.kt
index c71ec265f6..5df3fb4f20 100644
--- a/buildSrc/src/main/kotlin/CommonJavaConfig.kt
+++ b/buildSrc/src/main/kotlin/CommonJavaConfig.kt
@@ -21,8 +21,9 @@ fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, javaRelease: Int =
.withType()
.matching { it.name == "compileJava" || it.name == "compileTestJava" }
.configureEach {
+ // TODO: re-enable this-escape when ANTLR suppresses it properly
val disabledLint = listOf(
- "processing", "path", "fallthrough", "serial", "overloads",
+ "processing", "path", "fallthrough", "serial", "overloads", "this-escape",
)
options.release.set(javaRelease)
options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" })
diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt
index b39ee71939..cdf30b7a8f 100644
--- a/buildSrc/src/main/kotlin/PlatformConfig.kt
+++ b/buildSrc/src/main/kotlin/PlatformConfig.kt
@@ -11,7 +11,7 @@ import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.register
import kotlin.collections.set
-fun Project.applyPlatformAndCoreConfiguration(javaRelease: Int = 17) {
+fun Project.applyPlatformAndCoreConfiguration(javaRelease: Int = 21) {
applyCommonConfiguration()
apply(plugin = "java")
apply(plugin = "maven-publish")
diff --git a/gradle.properties b/gradle.properties
index b9fb782bcf..1642c4490e 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -4,5 +4,5 @@ version=7.3.1-SNAPSHOT
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true
-loom.version=1.5.6
-mixin.version=0.12.5+mixin.0.8.5
+loom.version=1.6.6
+mixin.version=0.13.2+mixin.0.8.5
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 0ae0b6bc14..0b145f0b92 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -16,11 +16,11 @@ rootProject.name = "worldedit"
include("worldedit-libs")
-listOf("1.18.2", "1.19.4", "1.20", "1.20.2", "1.20.4").forEach {
+listOf("1.19.4", "1.20", "1.20.2", "1.20.4").forEach {
include("worldedit-bukkit:adapters:adapter-$it")
}
-listOf("bukkit", "core", "sponge", "fabric", "forge", "cli").forEach {
+listOf("bukkit", "core", "fabric", "forge", "cli").forEach {
include("worldedit-libs:$it")
include("worldedit-$it")
}
diff --git a/verification/build.gradle.kts b/verification/build.gradle.kts
index 98aea05f62..d855e6208a 100644
--- a/verification/build.gradle.kts
+++ b/verification/build.gradle.kts
@@ -43,7 +43,7 @@ tasks.check {
// Generic setup for all tasks
// Pull the version before our current version.
val baseVersion = "(,${rootProject.version.toString().substringBefore("-SNAPSHOT")}["
-for (projectFragment in listOf("bukkit", "cli", "core", "fabric", "forge", "sponge")) {
+for (projectFragment in listOf("bukkit", "cli", "core", "fabric", "forge")) {
val capitalizedFragment =
projectFragment.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.ROOT) else it.toString() }
val proj = project(":worldedit-$projectFragment")
diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts
index 17a8a7cf46..96f859cba5 100644
--- a/worldedit-core/build.gradle.kts
+++ b/worldedit-core/build.gradle.kts
@@ -57,7 +57,7 @@ dependencies {
"implementation"("it.unimi.dsi:fastutil")
- val antlrVersion = "4.9.1"
+ val antlrVersion = "4.13.1"
"antlr"("org.antlr:antlr4:$antlrVersion")
"implementation"("org.antlr:antlr4-runtime:$antlrVersion")
diff --git a/worldedit-core/doctools/build.gradle.kts b/worldedit-core/doctools/build.gradle.kts
index 6f2123f20f..f51cc415ea 100644
--- a/worldedit-core/doctools/build.gradle.kts
+++ b/worldedit-core/doctools/build.gradle.kts
@@ -1,16 +1,10 @@
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
plugins {
- kotlin("jvm") version "1.8.20"
+ kotlin("jvm") version "1.9.23"
application
}
applyCommonConfiguration()
-tasks.withType {
- kotlinOptions.jvmTarget = "17"
-}
-
application.mainClass.set("com.sk89q.worldedit.internal.util.DocumentationPrinter")
tasks.named("run") {
workingDir = rootProject.projectDir
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java
index 8d8de2af7b..2132f727e9 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java
@@ -22,6 +22,7 @@
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.JarURLConnection;
+import java.net.URI;
import java.net.URL;
import java.util.function.Supplier;
import java.util.jar.Attributes;
@@ -72,8 +73,7 @@ public static WorldEditManifest load() {
}
try {
- URL url = new URL(classPath);
- JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
+ JarURLConnection jarConnection = (JarURLConnection) URI.create(classPath).toURL().openConnection();
Manifest manifest = jarConnection.getManifest();
return manifest.getMainAttributes();
} catch (IOException e) {
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java
index 74cc77738b..36935125af 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java
@@ -55,6 +55,7 @@ public class BaseEntity implements NbtValued {
* @param nbtData NBT data
* @deprecated Use {@link BaseEntity#BaseEntity(EntityType, LazyReference)}
*/
+ @SuppressWarnings("this-escape")
@Deprecated
public BaseEntity(EntityType type, CompoundTag nbtData) {
this(type);
@@ -67,6 +68,7 @@ public BaseEntity(EntityType type, CompoundTag nbtData) {
* @param type the entity type
* @param nbtData NBT data
*/
+ @SuppressWarnings("this-escape")
public BaseEntity(EntityType type, LazyReference nbtData) {
this(type);
setNbtReference(nbtData);
@@ -86,6 +88,7 @@ public BaseEntity(EntityType type) {
*
* @param other the object to clone
*/
+ @SuppressWarnings("this-escape")
public BaseEntity(BaseEntity other) {
checkNotNull(other);
this.type = other.getType();
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java
index dd93c8527d..91a64ba38b 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java
@@ -43,6 +43,7 @@ public class BlockChangeLimiter extends AbstractDelegateExtent {
* @param extent the extent
* @param limit the limit (>= 0) or -1 for no limit
*/
+ @SuppressWarnings("this-escape") // Unlikely anyone is extending this in practice
public BlockChangeLimiter(Extent extent, int limit) {
super(extent);
setLimit(limit);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java
index 30fde408ce..b54baed6e0 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java
@@ -276,17 +276,13 @@ public void contract(BlockVector3... changes) throws RegionOperationException {
@Override
public void shift(BlockVector3 change) throws RegionOperationException {
- final double changeX = change.x();
- final double changeY = change.y();
- final double changeZ = change.z();
-
for (int i = 0; i < points.size(); ++i) {
BlockVector2 point = points.get(i);
- points.set(i, BlockVector2.at(point.x() + changeX, point.z() + changeZ));
+ points.set(i, BlockVector2.at(point.x() + change.x(), point.z() + change.z()));
}
- minY += changeY;
- maxY += changeY;
+ minY += change.y();
+ maxY += change.y();
recalculate();
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ForwardSeekableInputStream.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ForwardSeekableInputStream.java
index 3fb87bde35..328bfdb8cf 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ForwardSeekableInputStream.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ForwardSeekableInputStream.java
@@ -60,7 +60,7 @@ public boolean markSupported() {
@Override
public int read(byte[] b, int off, int len) throws IOException {
- int read = super.read(b, off, len);
+ int read = parent.read(b, off, len);
position += read;
return read;
}
@@ -86,6 +86,7 @@ public long skip(long n) throws IOException {
public void seek(long n) throws IOException {
long diff = n - position;
+ System.err.println("Seek to " + n + " from position " + position + " using " + diff);
if (diff < 0) {
throw new IOException("Can't seek backwards");
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/net/HttpRequest.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/net/HttpRequest.java
index cdcb894ead..b06e81f826 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/net/HttpRequest.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/net/HttpRequest.java
@@ -353,7 +353,7 @@ public static HttpRequest request(String method, URL url) {
*/
public static URL url(String url) {
try {
- return new URL(url);
+ return URI.create(url).toURL();
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
@@ -367,12 +367,7 @@ public static URL url(String url) {
*/
private static URL reformat(URL existing) {
try {
- URL url = new URL(existing.toString());
- URI uri = new URI(
- url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(),
- url.getPath(), url.getQuery(), url.getRef());
- url = uri.toURL();
- return url;
+ return existing.toURI().toURL();
} catch (MalformedURLException | URISyntaxException e) {
return existing;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java
index a5bf59e4f7..0e66ac24cb 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java
@@ -24,6 +24,7 @@
import com.sk89q.worldedit.util.net.HttpRequest;
import java.io.IOException;
+import java.net.URI;
import java.net.URL;
import java.util.Map;
import java.util.concurrent.Callable;
@@ -82,7 +83,7 @@ public URL call() throws IOException, InterruptedException {
.execute()
.expectResponseCode(200, 204);
- return new URL(response.viewUrl);
+ return URI.create(response.viewUrl).toURL();
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/FutureForwardingTask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/FutureForwardingTask.java
index 07cde87f10..a30b523dd5 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/FutureForwardingTask.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/FutureForwardingTask.java
@@ -82,21 +82,22 @@ public V get(long timeout, TimeUnit unit) throws InterruptedException, Execution
return future.get(timeout, unit);
}
+ // TODO: consider deprecating in favor of Future.State?
@Override
- public State getState() {
+ public Task.State getState() {
if (isCancelled()) {
- return State.CANCELLED;
+ return Task.State.CANCELLED;
} else if (isDone()) {
try {
get();
- return State.SUCCEEDED;
+ return Task.State.SUCCEEDED;
} catch (InterruptedException e) {
- return State.CANCELLED;
+ return Task.State.CANCELLED;
} catch (ExecutionException e) {
- return State.FAILED;
+ return Task.State.FAILED;
}
} else {
- return State.RUNNING;
+ return Task.State.RUNNING;
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/translation/TranslationManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/translation/TranslationManager.java
index ddeecbcced..432383fb87 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/translation/TranslationManager.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/translation/TranslationManager.java
@@ -158,7 +158,7 @@ private MessageFormat getTranslation(Locale locale, String key) {
// Recurse into other options if not already at the base condition (defaultLocale)
if (!locale.getCountry().isEmpty()) {
// try without country modifier
- return getTranslation(new Locale(locale.getLanguage()), key);
+ return getTranslation(Locale.of(locale.getLanguage()), key);
}
// otherwise, try the default locale
return getTranslation(defaultLocale, key);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java
index 331c110374..27cfe95270 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java
@@ -49,21 +49,28 @@ public class BlockType implements Keyed {
private final Function values;
private final LazyReference defaultState
= LazyReference.from(this::computeDefaultState);
+ @SuppressWarnings("this-escape")
private final LazyReference emptyFuzzy
= LazyReference.from(() -> new FuzzyBlockState(this));
+ @SuppressWarnings("this-escape")
private final LazyReference
*/
@SuppressWarnings({ "UnnecessarilyQualifiedStaticUsage", "unchecked", "rawtypes" })
-class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.world.DataFixer {
+class NeoForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.world.DataFixer {
@SuppressWarnings("unchecked")
@Override
@@ -180,7 +181,7 @@ private static String fixName(String key, int srcVer, TypeReference type) {
private static final NbtOps OPS_NBT = NbtOps.INSTANCE;
private static final int LEGACY_VERSION = 1343;
private static int DATA_VERSION;
- private static ForgeDataFixer INSTANCE;
+ private static NeoForgeDataFixer INSTANCE;
private final Map> converters = new EnumMap<>(LegacyType.class);
private final Map> inspectors = new EnumMap<>(LegacyType.class);
@@ -211,7 +212,7 @@ public TypeReference getDFUType() {
}
}
- ForgeDataFixer(int dataVersion) {
+ NeoForgeDataFixer(int dataVersion) {
super(dataVersion);
DATA_VERSION = dataVersion;
INSTANCE = this;
@@ -252,7 +253,7 @@ public Dynamic update(TypeReference type, Dynamic dynamic, int sourceV
}
private net.minecraft.nbt.CompoundTag convert(LegacyType type, net.minecraft.nbt.CompoundTag cmp, int sourceVer, int desiredVersion) {
- List converters = ForgeDataFixer.this.converters.get(type);
+ List converters = NeoForgeDataFixer.this.converters.get(type);
if (converters != null && !converters.isEmpty()) {
for (DataConverter converter : converters) {
int dataVersion = converter.getDataVersion();
@@ -262,7 +263,7 @@ private net.minecraft.nbt.CompoundTag convert(LegacyType type, net.minecraft.nbt
}
}
- List inspectors = ForgeDataFixer.this.inspectors.get(type);
+ List inspectors = NeoForgeDataFixer.this.inspectors.get(type);
if (inspectors != null && !inspectors.isEmpty()) {
for (DataInspector inspector : inspectors) {
cmp = inspector.inspect(cmp, sourceVer, desiredVersion);
@@ -818,7 +819,7 @@ public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp,
private static class DataInspectorEntity implements DataInspector {
- private static final Logger a = LogManager.getLogger(ForgeDataFixer.class);
+ private static final Logger a = LogManager.getLogger(NeoForgeDataFixer.class);
DataInspectorEntity() {
}
@@ -893,7 +894,7 @@ private static class DataInspectorItemList extends DataInspectorTagged {
net.minecraft.nbt.CompoundTag inspectChecked(net.minecraft.nbt.CompoundTag nbttagcompound, int sourceVer, int targetVer) {
for (String s : this.keys) {
- ForgeDataFixer.convertItems(nbttagcompound, s, sourceVer, targetVer);
+ NeoForgeDataFixer.convertItems(nbttagcompound, s, sourceVer, targetVer);
}
return nbttagcompound;
@@ -911,7 +912,7 @@ private static class DataInspectorItem extends DataInspectorTagged {
net.minecraft.nbt.CompoundTag inspectChecked(net.minecraft.nbt.CompoundTag nbttagcompound, int sourceVer, int targetVer) {
for (String key : this.keys) {
- ForgeDataFixer.convertItem(nbttagcompound, key, sourceVer, targetVer);
+ NeoForgeDataFixer.convertItem(nbttagcompound, key, sourceVer, targetVer);
}
return nbttagcompound;
@@ -1882,7 +1883,7 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
if (object == null) {
try {
- object = Component.Serializer.fromJson(s);
+ object = Component.Serializer.fromJson(s, ServerLifecycleHooks.getCurrentServer().registryAccess());
} catch (JsonParseException jsonparseexception1) {
;
}
@@ -1890,7 +1891,7 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
if (object == null) {
try {
- object = Component.Serializer.fromJsonLenient(s);
+ object = Component.Serializer.fromJsonLenient(s, ServerLifecycleHooks.getCurrentServer().registryAccess());
} catch (JsonParseException jsonparseexception2) {
;
}
@@ -1904,7 +1905,7 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
object = Component.literal("");
}
- nbttaglist.set(i, StringTag.valueOf(Component.Serializer.toJson((Component) object)));
+ nbttaglist.set(i, StringTag.valueOf(Component.Serializer.toJson((Component) object, ServerLifecycleHooks.getCurrentServer().registryAccess())));
}
nbttagcompound1.put("pages", nbttaglist);
@@ -2412,7 +2413,7 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
private static class DataConverterBedBlock implements DataConverter {
- private static final Logger a = LogManager.getLogger(ForgeDataFixer.class);
+ private static final Logger a = LogManager.getLogger(NeoForgeDataFixer.class);
DataConverterBedBlock() {
}
@@ -2547,7 +2548,7 @@ private void convert(net.minecraft.nbt.CompoundTag nbttagcompound, String s) {
if (object == null) {
try {
- object = Component.Serializer.fromJson(s1);
+ object = Component.Serializer.fromJson(s1, ServerLifecycleHooks.getCurrentServer().registryAccess());
} catch (JsonParseException jsonparseexception1) {
;
}
@@ -2555,7 +2556,7 @@ private void convert(net.minecraft.nbt.CompoundTag nbttagcompound, String s) {
if (object == null) {
try {
- object = Component.Serializer.fromJsonLenient(s1);
+ object = Component.Serializer.fromJsonLenient(s1, ServerLifecycleHooks.getCurrentServer().registryAccess());
} catch (JsonParseException jsonparseexception2) {
;
}
@@ -2569,7 +2570,7 @@ private void convert(net.minecraft.nbt.CompoundTag nbttagcompound, String s) {
object = Component.literal("");
}
- nbttagcompound.putString(s, Component.Serializer.toJson((Component) object));
+ nbttagcompound.putString(s, Component.Serializer.toJson((Component) object, ServerLifecycleHooks.getCurrentServer().registryAccess()));
}
}
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntityProperties.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeEntityProperties.java
similarity index 96%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntityProperties.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeEntityProperties.java
index 5d2175ee85..7963f985b1 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntityProperties.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeEntityProperties.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge;
+package com.sk89q.worldedit.neoforge;
import com.sk89q.worldedit.entity.metadata.EntityProperties;
import net.minecraft.server.level.ServerPlayer;
@@ -45,11 +45,11 @@
import static com.google.common.base.Preconditions.checkNotNull;
-public class ForgeEntityProperties implements EntityProperties {
+public class NeoForgeEntityProperties implements EntityProperties {
private final Entity entity;
- public ForgeEntityProperties(Entity entity) {
+ public NeoForgeEntityProperties(Entity entity) {
checkNotNull(entity);
this.entity = entity;
}
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemCategoryRegistry.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeItemCategoryRegistry.java
similarity index 74%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemCategoryRegistry.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeItemCategoryRegistry.java
index 2862a09473..b9c5dcac7d 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemCategoryRegistry.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeItemCategoryRegistry.java
@@ -17,34 +17,32 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge;
+package com.sk89q.worldedit.neoforge;
import com.google.common.collect.ImmutableSet;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.registry.ItemCategoryRegistry;
+import net.minecraft.core.Holder;
+import net.minecraft.core.HolderSet;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
-import net.minecraft.world.item.Item;
-import net.minecraftforge.registries.ForgeRegistries;
-import net.minecraftforge.registries.tags.ITagManager;
+import net.neoforged.neoforge.server.ServerLifecycleHooks;
-import java.util.Objects;
import java.util.Set;
-public class ForgeItemCategoryRegistry implements ItemCategoryRegistry {
+public class NeoForgeItemCategoryRegistry implements ItemCategoryRegistry {
@Override
public Set getCategorisedByName(String category) {
- ITagManager- tags = Objects.requireNonNull(
- ForgeRegistries.ITEMS.tags(), "no item tags registry"
- );
- return tags
+ return ServerLifecycleHooks.getCurrentServer().registryAccess().registryOrThrow(Registries.ITEM)
.getTag(TagKey.create(
Registries.ITEM,
new ResourceLocation(category)
))
.stream()
- .map(ForgeAdapter::adapt)
+ .flatMap(HolderSet.Named::stream)
+ .map(Holder::value)
+ .map(NeoForgeAdapter::adapt)
.collect(ImmutableSet.toImmutableSet());
}
}
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemRegistry.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeItemRegistry.java
similarity index 85%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemRegistry.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeItemRegistry.java
index cd8a1e1409..7b9d2a9baf 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemRegistry.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeItemRegistry.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge;
+package com.sk89q.worldedit.neoforge;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.util.formatting.text.Component;
@@ -25,19 +25,19 @@
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.registry.BundledItemRegistry;
-public class ForgeItemRegistry extends BundledItemRegistry {
+public class NeoForgeItemRegistry extends BundledItemRegistry {
@Override
public Component getRichName(ItemType itemType) {
return TranslatableComponent.of(
- ForgeAdapter.adapt(itemType).getDescriptionId()
+ NeoForgeAdapter.adapt(itemType).getDescriptionId()
);
}
@Override
public Component getRichName(BaseItemStack itemStack) {
return TranslatableComponent.of(
- ForgeAdapter.adapt(itemStack).getDescriptionId()
+ NeoForgeAdapter.adapt(itemStack).getDescriptionId()
);
}
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePermissionsProvider.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgePermissionsProvider.java
similarity index 63%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePermissionsProvider.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgePermissionsProvider.java
index cdfe1dae6d..ce48cd2d2f 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePermissionsProvider.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgePermissionsProvider.java
@@ -17,29 +17,29 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge;
+package com.sk89q.worldedit.neoforge;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.GameType;
-import net.minecraftforge.server.ServerLifecycleHooks;
+import net.neoforged.neoforge.server.ServerLifecycleHooks;
-public interface ForgePermissionsProvider {
+public interface NeoForgePermissionsProvider {
boolean hasPermission(ServerPlayer player, String permission);
void registerPermission(String permission);
- class VanillaPermissionsProvider implements ForgePermissionsProvider {
+ class VanillaPermissionsProvider implements NeoForgePermissionsProvider {
- private final ForgePlatform platform;
+ private final NeoForgePlatform platform;
- public VanillaPermissionsProvider(ForgePlatform platform) {
+ public VanillaPermissionsProvider(NeoForgePlatform platform) {
this.platform = platform;
}
@Override
public boolean hasPermission(ServerPlayer player, String permission) {
- ForgeConfiguration configuration = platform.getConfiguration();
+ NeoForgeConfiguration configuration = platform.getConfiguration();
return configuration.cheatMode
|| ServerLifecycleHooks.getCurrentServer().getPlayerList().isOp(player.getGameProfile())
|| (configuration.creativeEnable && player.gameMode.getGameModeForPlayer() == GameType.CREATIVE);
@@ -49,18 +49,4 @@ public boolean hasPermission(ServerPlayer player, String permission) {
public void registerPermission(String permission) {
}
}
-
- // TODO Re-add when Sponge for 1.14 is out
- // class SpongePermissionsProvider implements ForgePermissionsProvider {
- //
- // @Override
- // public boolean hasPermission(EntityPlayerMP player, String permission) {
- // return ((Player) player).hasPermission(permission);
- // }
- //
- // @Override
- // public void registerPermission(ICommand command, String permission) {
- //
- // }
- // }
}
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgePlatform.java
similarity index 83%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgePlatform.java
index d46e9594b3..5b8a57af1c 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgePlatform.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge;
+package com.sk89q.worldedit.neoforge;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
@@ -29,7 +29,7 @@
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.MultiUserPlatform;
import com.sk89q.worldedit.extension.platform.Preference;
-import com.sk89q.worldedit.forge.internal.ExtendedChunk;
+import com.sk89q.worldedit.neoforge.internal.ExtendedChunk;
import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.util.io.ResourceLoader;
import com.sk89q.worldedit.world.DataFixer;
@@ -37,6 +37,7 @@
import com.sk89q.worldedit.world.registry.Registries;
import net.minecraft.SharedConstants;
import net.minecraft.commands.Commands;
+import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.DedicatedServer;
@@ -45,7 +46,7 @@
import net.minecraft.server.players.PlayerList;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.storage.ServerLevelData;
-import net.minecraftforge.server.ServerLifecycleHooks;
+import net.neoforged.neoforge.server.ServerLifecycleHooks;
import org.enginehub.piston.Command;
import org.enginehub.piston.CommandManager;
@@ -60,17 +61,17 @@
import static java.util.stream.Collectors.toList;
-class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
+class NeoForgePlatform extends AbstractPlatform implements MultiUserPlatform {
- private final ForgeWorldEdit mod;
- private final ForgeDataFixer dataFixer;
- private @Nullable ForgeWatchdog watchdog;
+ private final NeoForgeWorldEdit mod;
+ private final NeoForgeDataFixer dataFixer;
+ private @Nullable NeoForgeWatchdog watchdog;
private boolean hookingEvents = false;
- private final ResourceLoader resourceLoader = new ForgeResourceLoader(WorldEdit.getInstance());
+ private final ResourceLoader resourceLoader = new NeoForgeResourceLoader(WorldEdit.getInstance());
- ForgePlatform(ForgeWorldEdit mod) {
+ NeoForgePlatform(NeoForgeWorldEdit mod) {
this.mod = mod;
- this.dataFixer = new ForgeDataFixer(getDataVersion());
+ this.dataFixer = new NeoForgeDataFixer(getDataVersion());
}
boolean isHookingEvents() {
@@ -84,7 +85,7 @@ public ResourceLoader getResourceLoader() {
@Override
public Registries getRegistries() {
- return ForgeRegistries.getInstance();
+ return NeoForgeRegistries.getInstance();
}
@Override
@@ -99,7 +100,7 @@ public DataFixer getDataFixer() {
@Override
public boolean isValidMobType(String type) {
- return net.minecraftforge.registries.ForgeRegistries.ENTITY_TYPES.containsKey(new ResourceLocation(type));
+ return BuiltInRegistries.ENTITY_TYPE.containsKey(new ResourceLocation(type));
}
@Override
@@ -115,11 +116,11 @@ public int schedule(long delay, long period, Runnable task) {
@Override
@Nullable
- public ForgeWatchdog getWatchdog() {
+ public NeoForgeWatchdog getWatchdog() {
if (watchdog == null) {
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
if (server instanceof DedicatedServer) {
- watchdog = new ForgeWatchdog((DedicatedServer) server);
+ watchdog = new NeoForgeWatchdog((DedicatedServer) server);
}
}
return watchdog;
@@ -130,7 +131,7 @@ public List extends World> getWorlds() {
Iterable worlds = ServerLifecycleHooks.getCurrentServer().getAllLevels();
List ret = new ArrayList<>();
for (ServerLevel world : worlds) {
- ret.add(new ForgeWorld(world));
+ ret.add(new NeoForgeWorld(world));
}
return ret;
}
@@ -138,23 +139,23 @@ public List extends World> getWorlds() {
@Nullable
@Override
public Player matchPlayer(Player player) {
- if (player instanceof ForgePlayer) {
+ if (player instanceof NeoForgePlayer) {
return player;
} else {
ServerPlayer entity = ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayerByName(player.getName());
- return entity != null ? new ForgePlayer(entity) : null;
+ return entity != null ? new NeoForgePlayer(entity) : null;
}
}
@Nullable
@Override
public World matchWorld(World world) {
- if (world instanceof ForgeWorld) {
+ if (world instanceof NeoForgeWorld) {
return world;
} else {
for (ServerLevel ws : ServerLifecycleHooks.getCurrentServer().getAllLevels()) {
if (((ServerLevelData) ws.getLevelData()).getLevelName().equals(world.getName())) {
- return new ForgeWorld(ws);
+ return new NeoForgeWorld(ws);
}
}
@@ -170,13 +171,13 @@ public void registerCommands(CommandManager manager) {
}
Commands mcMan = server.getCommands();
- for (Command command : manager.getAllCommands().collect(toList())) {
+ for (Command command : manager.getAllCommands().toList()) {
CommandWrapper.register(mcMan.getDispatcher(), command);
Set perms = command.getCondition().as(PermissionCondition.class)
.map(PermissionCondition::getPermissions)
.orElseGet(Collections::emptySet);
if (!perms.isEmpty()) {
- perms.forEach(ForgeWorldEdit.inst.getPermissionsProvider()::registerPermission);
+ perms.forEach(NeoForgeWorldEdit.inst.getPermissionsProvider()::registerPermission);
}
}
}
@@ -187,7 +188,7 @@ public void setGameHooksEnabled(boolean enabled) {
}
@Override
- public ForgeConfiguration getConfiguration() {
+ public NeoForgeConfiguration getConfiguration() {
return mod.getConfig();
}
@@ -253,7 +254,7 @@ public Collection getConnectedUsers() {
PlayerList scm = ServerLifecycleHooks.getCurrentServer().getPlayerList();
for (ServerPlayer entity : scm.getPlayers()) {
if (entity != null) {
- users.add(new ForgePlayer(entity));
+ users.add(new NeoForgePlayer(entity));
}
}
return users;
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgePlayer.java
similarity index 86%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgePlayer.java
index bccd06fc98..fddd8bc453 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgePlayer.java
@@ -17,18 +17,18 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge;
+package com.sk89q.worldedit.neoforge;
import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
import com.sk89q.worldedit.extent.inventory.BlockBag;
-import com.sk89q.worldedit.forge.internal.NBTConverter;
-import com.sk89q.worldedit.forge.net.handler.WECUIPacketHandler;
import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
+import com.sk89q.worldedit.neoforge.internal.NBTConverter;
+import com.sk89q.worldedit.neoforge.net.handler.WECUIPacketHandler;
import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location;
@@ -40,10 +40,8 @@
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
-import io.netty.buffer.Unpooled;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
-import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
import net.minecraft.server.level.ServerLevel;
@@ -51,18 +49,18 @@
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntityType;
+import net.neoforged.neoforge.network.PacketDistributor;
import org.enginehub.linbus.tree.LinCompoundTag;
-import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.UUID;
import javax.annotation.Nullable;
-public class ForgePlayer extends AbstractPlayerActor {
+public class NeoForgePlayer extends AbstractPlayerActor {
private final ServerPlayer player;
- protected ForgePlayer(ServerPlayer player) {
+ protected NeoForgePlayer(ServerPlayer player) {
this.player = player;
ThreadSafeCache.getInstance().getOnlineIds().add(getUniqueId());
}
@@ -79,7 +77,7 @@ public BaseItemStack getItemInHand(HandSide handSide) {
? InteractionHand.MAIN_HAND
: InteractionHand.OFF_HAND
);
- return ForgeAdapter.adapt(is);
+ return NeoForgeAdapter.adapt(is);
}
@Override
@@ -96,7 +94,7 @@ public BaseEntity getState() {
public Location getLocation() {
Vector3 position = Vector3.at(this.player.getX(), this.player.getY(), this.player.getZ());
return new Location(
- ForgeWorldEdit.inst.getWorld(this.player.serverLevel()),
+ NeoForgeWorldEdit.inst.getWorld(this.player.serverLevel()),
position,
this.player.getYRot(),
this.player.getXRot());
@@ -104,7 +102,7 @@ public Location getLocation() {
@Override
public boolean setLocation(Location location) {
- ServerLevel level = ForgeAdapter.adapt((World) location.getExtent());
+ ServerLevel level = NeoForgeAdapter.adapt((World) location.getExtent());
this.player.teleportTo(
level,
location.getX(), location.getY(), location.getZ(),
@@ -116,12 +114,12 @@ public boolean setLocation(Location location) {
@Override
public World getWorld() {
- return ForgeWorldEdit.inst.getWorld(this.player.serverLevel());
+ return NeoForgeWorldEdit.inst.getWorld(this.player.serverLevel());
}
@Override
public void giveItem(BaseItemStack itemStack) {
- this.player.getInventory().add(ForgeAdapter.adapt(itemStack));
+ this.player.getInventory().add(NeoForgeAdapter.adapt(itemStack));
}
@Override
@@ -131,8 +129,7 @@ public void dispatchCUIEvent(CUIEvent event) {
if (params.length > 0) {
send = send + "|" + StringUtil.joinString(params, "|");
}
- FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.copiedBuffer(send, StandardCharsets.UTF_8));
- WECUIPacketHandler.send(this.player.connection.getConnection(), buffer);
+ PacketDistributor.sendToPlayer(this.player, new WECUIPacketHandler.CuiPacket(send));
}
private void sendMessage(net.minecraft.network.chat.Component textComponent) {
@@ -168,7 +165,8 @@ public void printError(String msg) {
@Override
public void print(Component component) {
sendMessage(net.minecraft.network.chat.Component.Serializer.fromJson(
- GsonComponentSerializer.INSTANCE.serialize(WorldEditText.format(component, getLocale()))
+ GsonComponentSerializer.INSTANCE.serialize(WorldEditText.format(component, getLocale())),
+ this.player.registryAccess()
));
}
@@ -198,7 +196,7 @@ public BlockBag getInventoryBlockBag() {
@Override
public boolean hasPermission(String perm) {
- return ForgeWorldEdit.inst.getPermissionsProvider().hasPermission(player, perm);
+ return NeoForgeWorldEdit.inst.getPermissionsProvider().hasPermission(player, perm);
}
@Nullable
@@ -209,7 +207,7 @@ public T getFacet(Class extends T> cls) {
@Override
public boolean isAllowedToFly() {
- return player.getAbilities().mayfly;
+ return player.mayFly();
}
@Override
@@ -228,19 +226,19 @@ public Locale getLocale() {
@Override
public > void sendFakeBlock(BlockVector3 pos, B block) {
World world = getWorld();
- if (!(world instanceof ForgeWorld)) {
+ if (!(world instanceof NeoForgeWorld)) {
return;
}
- BlockPos loc = ForgeAdapter.toBlockPos(pos);
+ BlockPos loc = NeoForgeAdapter.toBlockPos(pos);
if (block == null) {
final ClientboundBlockUpdatePacket packetOut = new ClientboundBlockUpdatePacket(
- ((ForgeWorld) world).getWorld(),
+ ((NeoForgeWorld) world).getWorld(),
loc
);
player.connection.send(packetOut);
} else {
player.connection.send(new ClientboundBlockUpdatePacket(
- loc, ForgeAdapter.adapt(block.toImmutableState())
+ loc, NeoForgeAdapter.adapt(block.toImmutableState())
));
if (block instanceof BaseBlock baseBlock && block.getBlockType().equals(BlockTypes.STRUCTURE_BLOCK)) {
final LinCompoundTag nbtData = baseBlock.getNbt();
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeRegistries.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeRegistries.java
similarity index 79%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeRegistries.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeRegistries.java
index 55d77abf5b..2aa4bb7604 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeRegistries.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeRegistries.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge;
+package com.sk89q.worldedit.neoforge;
import com.sk89q.worldedit.world.registry.BiomeRegistry;
import com.sk89q.worldedit.world.registry.BlockCategoryRegistry;
@@ -29,14 +29,14 @@
/**
* World data for the Forge platform.
*/
-class ForgeRegistries extends BundledRegistries {
+class NeoForgeRegistries extends BundledRegistries {
- private static final ForgeRegistries INSTANCE = new ForgeRegistries();
- private final BlockRegistry blockRegistry = new ForgeBlockRegistry();
- private final BiomeRegistry biomeRegistry = new ForgeBiomeRegistry();
- private final ItemRegistry itemRegistry = new ForgeItemRegistry();
- private final BlockCategoryRegistry blockCategoryRegistry = new ForgeBlockCategoryRegistry();
- private final ItemCategoryRegistry itemCategoryRegistry = new ForgeItemCategoryRegistry();
+ private static final NeoForgeRegistries INSTANCE = new NeoForgeRegistries();
+ private final BlockRegistry blockRegistry = new NeoForgeBlockRegistry();
+ private final BiomeRegistry biomeRegistry = new NeoForgeBiomeRegistry();
+ private final ItemRegistry itemRegistry = new NeoForgeItemRegistry();
+ private final BlockCategoryRegistry blockCategoryRegistry = new NeoForgeBlockCategoryRegistry();
+ private final ItemCategoryRegistry itemCategoryRegistry = new NeoForgeItemCategoryRegistry();
@Override
public BlockRegistry getBlockRegistry() {
@@ -68,7 +68,7 @@ public ItemCategoryRegistry getItemCategoryRegistry() {
*
* @return an instance
*/
- public static ForgeRegistries getInstance() {
+ public static NeoForgeRegistries getInstance() {
return INSTANCE;
}
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeResourceLoader.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeResourceLoader.java
similarity index 91%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeResourceLoader.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeResourceLoader.java
index cb480efdb2..57dda7565f 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeResourceLoader.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeResourceLoader.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge;
+package com.sk89q.worldedit.neoforge;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.util.io.WorldEditResourceLoader;
@@ -26,9 +26,9 @@
import java.net.URI;
import java.net.URL;
-public class ForgeResourceLoader extends WorldEditResourceLoader {
+public class NeoForgeResourceLoader extends WorldEditResourceLoader {
- public ForgeResourceLoader(WorldEdit worldEdit) {
+ public NeoForgeResourceLoader(WorldEdit worldEdit) {
super(worldEdit);
}
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWatchdog.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWatchdog.java
similarity index 89%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWatchdog.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWatchdog.java
index 5cf43d0254..daa1cbf029 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWatchdog.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWatchdog.java
@@ -17,17 +17,17 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge;
+package com.sk89q.worldedit.neoforge;
import com.sk89q.worldedit.extension.platform.Watchdog;
import net.minecraft.Util;
import net.minecraft.server.dedicated.DedicatedServer;
-class ForgeWatchdog implements Watchdog {
+class NeoForgeWatchdog implements Watchdog {
private final DedicatedServer server;
- ForgeWatchdog(DedicatedServer server) {
+ NeoForgeWatchdog(DedicatedServer server) {
this.server = server;
}
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWorld.java
similarity index 87%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWorld.java
index a704dfad78..f6a9569e42 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWorld.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge;
+package com.sk89q.worldedit.neoforge;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
@@ -34,18 +34,16 @@
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent;
-import com.sk89q.worldedit.forge.internal.ForgeEntity;
-import com.sk89q.worldedit.forge.internal.ForgeServerLevelDelegateProxy;
-import com.sk89q.worldedit.forge.internal.ForgeWorldNativeAccess;
-import com.sk89q.worldedit.forge.internal.NBTConverter;
-import com.sk89q.worldedit.forge.internal.TileEntityUtils;
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.function.mask.Mask;
-import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
+import com.sk89q.worldedit.neoforge.internal.NBTConverter;
+import com.sk89q.worldedit.neoforge.internal.NeoForgeEntity;
+import com.sk89q.worldedit.neoforge.internal.NeoForgeServerLevelDelegateProxy;
+import com.sk89q.worldedit.neoforge.internal.NeoForgeWorldNativeAccess;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.Location;
@@ -92,9 +90,9 @@
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.chunk.ChunkAccess;
-import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.PalettedContainer;
+import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.WorldOptions;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
@@ -133,7 +131,7 @@
/**
* An adapter to Minecraft worlds for WorldEdit.
*/
-public class ForgeWorld extends AbstractWorld {
+public class NeoForgeWorld extends AbstractWorld {
private static final RandomSource random = RandomSource.create();
@@ -145,17 +143,17 @@ private static ResourceLocation getDimensionRegistryKey(ServerLevel world) {
}
private final WeakReference worldRef;
- private final ForgeWorldNativeAccess nativeAccess;
+ private final NeoForgeWorldNativeAccess nativeAccess;
/**
* Construct a new world.
*
* @param world the world
*/
- ForgeWorld(ServerLevel world) {
+ NeoForgeWorld(ServerLevel world) {
checkNotNull(world);
this.worldRef = new WeakReference<>(world);
- this.nativeAccess = new ForgeWorldNativeAccess(worldRef);
+ this.nativeAccess = new NeoForgeWorldNativeAccess(worldRef);
}
/**
@@ -198,20 +196,20 @@ public > boolean setBlock(BlockVector3 position, B
@Override
public Set applySideEffects(BlockVector3 position, BlockState previousType, SideEffectSet sideEffectSet) {
nativeAccess.applySideEffects(position, previousType, sideEffectSet);
- return Sets.intersection(ForgeWorldEdit.inst.getPlatform().getSupportedSideEffects(), sideEffectSet.getSideEffectsToApply());
+ return Sets.intersection(NeoForgeWorldEdit.inst.getPlatform().getSupportedSideEffects(), sideEffectSet.getSideEffectsToApply());
}
@Override
public int getBlockLightLevel(BlockVector3 position) {
checkNotNull(position);
- return getWorld().getLightEmission(ForgeAdapter.toBlockPos(position));
+ return getWorld().getLightEmission(NeoForgeAdapter.toBlockPos(position));
}
@Override
public boolean clearContainerBlockContents(BlockVector3 position) {
checkNotNull(position);
- BlockEntity tile = getWorld().getBlockEntity(ForgeAdapter.toBlockPos(position));
+ BlockEntity tile = getWorld().getBlockEntity(NeoForgeAdapter.toBlockPos(position));
if (tile instanceof Clearable) {
((Clearable) tile).clearContent();
return true;
@@ -228,7 +226,7 @@ public BiomeType getBiome(BlockVector3 position) {
}
private BiomeType getBiomeInChunk(BlockVector3 position, ChunkAccess chunk) {
- return ForgeAdapter.adapt(
+ return NeoForgeAdapter.adapt(
chunk.getNoiseBiome(position.x() >> 2, position.y() >> 2, position.z() >> 2).value()
);
}
@@ -255,7 +253,7 @@ public boolean setBiome(BlockVector3 position, BiomeType biome) {
@Override
public boolean useItem(BlockVector3 position, BaseItem item, Direction face) {
- ItemStack stack = ForgeAdapter.adapt(new BaseItemStack(item.getType(), item.getNbtReference(), 1));
+ ItemStack stack = NeoForgeAdapter.adapt(new BaseItemStack(item.getType(), item.getNbtReference(), 1));
ServerLevel world = getWorld();
final WorldEditFakePlayer fakePlayer;
try {
@@ -266,15 +264,15 @@ public boolean useItem(BlockVector3 position, BaseItem item, Direction face) {
fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, stack);
fakePlayer.absMoveTo(position.x(), position.y(), position.z(),
(float) face.toVector().toYaw(), (float) face.toVector().toPitch());
- final BlockPos blockPos = ForgeAdapter.toBlockPos(position);
- final BlockHitResult rayTraceResult = new BlockHitResult(ForgeAdapter.toVec3(position),
- ForgeAdapter.adapt(face), blockPos, false);
+ final BlockPos blockPos = NeoForgeAdapter.toBlockPos(position);
+ final BlockHitResult rayTraceResult = new BlockHitResult(NeoForgeAdapter.toVec3(position),
+ NeoForgeAdapter.adapt(face), blockPos, false);
UseOnContext itemUseContext = new UseOnContext(fakePlayer, InteractionHand.MAIN_HAND, rayTraceResult);
InteractionResult used = stack.onItemUseFirst(itemUseContext);
if (used != InteractionResult.SUCCESS) {
// try activating the block
- InteractionResult resultType = getWorld().getBlockState(blockPos)
- .use(world, fakePlayer, InteractionHand.MAIN_HAND, rayTraceResult);
+ InteractionResult resultType = getWorld().getBlockState(blockPos).useItemOn(stack, world, fakePlayer, InteractionHand.MAIN_HAND, rayTraceResult)
+ .result();
if (resultType.consumesAction()) {
used = resultType;
} else {
@@ -293,20 +291,20 @@ public void dropItem(Vector3 position, BaseItemStack item) {
return;
}
- ItemEntity entity = new ItemEntity(getWorld(), position.x(), position.y(), position.z(), ForgeAdapter.adapt(item));
+ ItemEntity entity = new ItemEntity(getWorld(), position.x(), position.y(), position.z(), NeoForgeAdapter.adapt(item));
entity.setPickUpDelay(10);
getWorld().addFreshEntity(entity);
}
@Override
public void simulateBlockMine(BlockVector3 position) {
- BlockPos pos = ForgeAdapter.toBlockPos(position);
+ BlockPos pos = NeoForgeAdapter.toBlockPos(position);
getWorld().destroyBlock(pos, true);
}
@Override
public boolean canPlaceAt(BlockVector3 position, BlockState blockState) {
- return ForgeAdapter.adapt(blockState).canSurvive(getWorld(), ForgeAdapter.toBlockPos(position));
+ return NeoForgeAdapter.adapt(blockState).canSurvive(getWorld(), NeoForgeAdapter.toBlockPos(position));
}
// For unmapped regen names, see Fabric!
@@ -332,11 +330,11 @@ private void doRegen(Region region, Extent extent, RegenOptions options) throws
WorldOptions originalOpts = levelProperties.worldGenOptions();
long seed = options.getSeed().orElse(originalWorld.getSeed());
- WorldOptions newOpts = options.getSeed().isPresent()
+
+ levelProperties.worldOptions = options.getSeed().isPresent()
? originalOpts.withSeed(OptionalLong.of(seed))
: originalOpts;
- levelProperties.worldOptions = newOpts;
ResourceKey worldRegKey = originalWorld.dimension();
try (ServerLevel serverWorld = new ServerLevel(
originalWorld.getServer(), Util.backgroundExecutor(), session,
@@ -394,12 +392,13 @@ private void regenForWorld(Region region, Extent extent, ServerLevel serverWorld
}
for (BlockVector3 vec : region) {
- BlockPos pos = ForgeAdapter.toBlockPos(vec);
+ BlockPos pos = NeoForgeAdapter.toBlockPos(vec);
ChunkAccess chunk = chunks.get(new ChunkPos(pos));
- BlockStateHolder> state = ForgeAdapter.adapt(chunk.getBlockState(pos));
+ BlockStateHolder> state = NeoForgeAdapter.adapt(chunk.getBlockState(pos));
BlockEntity blockEntity = chunk.getBlockEntity(pos);
if (blockEntity != null) {
- state = state.toBaseBlock(LazyReference.from(() -> NBTConverter.fromNative(blockEntity.saveWithFullMetadata())));
+ net.minecraft.nbt.CompoundTag tag = blockEntity.saveWithId(serverWorld.registryAccess());
+ state = state.toBaseBlock(LazyReference.from(() -> NBTConverter.fromNative(tag)));
}
extent.setBlock(vec, state.toBaseBlock());
@@ -415,8 +414,8 @@ private List> submitChunkLoadTasks(Region region,
// Pre-gen all the chunks
for (BlockVector2 chunk : region.getChunks()) {
chunkLoadings.add(
- world.getChunkSource().getChunkFutureMainThread(chunk.x(), chunk.z(), ChunkStatus.FEATURES, true)
- .thenApply(either -> either.left().orElse(null))
+ world.getChunkSource().getChunkFuture(chunk.x(), chunk.z(), ChunkStatus.FEATURES, true)
+ .thenApply(either -> either.orElse(null))
);
}
return chunkLoadings;
@@ -462,9 +461,9 @@ public boolean generateTree(TreeType type, EditSession editSession, BlockVector3
if (type == TreeType.CHORUS_PLANT) {
position = position.add(0, 1, 0);
}
- WorldGenLevel levelProxy = ForgeServerLevelDelegateProxy.newInstance(editSession, world);
+ WorldGenLevel levelProxy = NeoForgeServerLevelDelegateProxy.newInstance(editSession, world);
return generator != null && generator.place(
- levelProxy, chunkManager.getGenerator(), random, ForgeAdapter.toBlockPos(position)
+ levelProxy, chunkManager.getGenerator(), random, NeoForgeAdapter.toBlockPos(position)
);
}
@@ -472,8 +471,8 @@ public boolean generateFeature(ConfiguredFeatureType type, EditSession editSessi
ServerLevel world = getWorld();
ConfiguredFeature, ?> k = world.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).get(ResourceLocation.tryParse(type.id()));
ServerChunkCache chunkManager = world.getChunkSource();
- WorldGenLevel levelProxy = ForgeServerLevelDelegateProxy.newInstance(editSession, world);
- return k != null && k.place(levelProxy, chunkManager.getGenerator(), random, ForgeAdapter.toBlockPos(position));
+ WorldGenLevel levelProxy = NeoForgeServerLevelDelegateProxy.newInstance(editSession, world);
+ return k != null && k.place(levelProxy, chunkManager.getGenerator(), random, NeoForgeAdapter.toBlockPos(position));
}
@Override
@@ -485,7 +484,7 @@ public boolean generateStructure(StructureType type, EditSession editSession, Bl
}
ServerChunkCache chunkManager = world.getChunkSource();
- WorldGenLevel proxyLevel = ForgeServerLevelDelegateProxy.newInstance(editSession, world);
+ WorldGenLevel proxyLevel = NeoForgeServerLevelDelegateProxy.newInstance(editSession, world);
ChunkPos chunkPos = new ChunkPos(new BlockPos(position.x(), position.y(), position.z()));
StructureStart structureStart = k.generate(world.registryAccess(), chunkManager.getGenerator(), chunkManager.getGenerator().getBiomeSource(), chunkManager.randomState(), world.getStructureManager(), world.getSeed(), chunkPos, 0, proxyLevel, biome -> true);
@@ -502,7 +501,7 @@ public boolean generateStructure(StructureType type, EditSession editSession, Bl
@Override
public void checkLoadedChunk(BlockVector3 pt) {
- getWorld().getChunk(ForgeAdapter.toBlockPos(pt));
+ getWorld().getChunk(NeoForgeAdapter.toBlockPos(pt));
}
@Override
@@ -534,7 +533,7 @@ public void fixLighting(Iterable chunks) {
@Override
public boolean playEffect(Vector3 position, int type, int data) {
// TODO update sound API
- // getWorld().play(type, ForgeAdapter.toBlockPos(position.toBlockPoint()), data);
+ // getWorld().play(type, NeoForgeAdapter.toBlockPos(position.toBlockPoint()), data);
return true;
}
@@ -597,21 +596,16 @@ public int getMaxY() {
@Override
public BlockVector3 getSpawnPosition() {
- LevelData worldInfo = getWorld().getLevelData();
- return BlockVector3.at(
- worldInfo.getXSpawn(),
- worldInfo.getYSpawn(),
- worldInfo.getZSpawn()
- );
+ return NeoForgeAdapter.adapt(getWorld().getLevelData().getSpawnPos());
}
@Override
public BlockState getBlock(BlockVector3 position) {
net.minecraft.world.level.block.state.BlockState mcState = getWorld()
.getChunk(position.x() >> 4, position.z() >> 4)
- .getBlockState(ForgeAdapter.toBlockPos(position));
+ .getBlockState(NeoForgeAdapter.toBlockPos(position));
- return ForgeAdapter.adapt(mcState);
+ return NeoForgeAdapter.adapt(mcState);
}
@Override
@@ -620,7 +614,7 @@ public BaseBlock getFullBlock(BlockVector3 position) {
BlockEntity tile = getWorld().getChunk(pos).getBlockEntity(pos);
if (tile != null) {
- net.minecraft.nbt.CompoundTag tag = TileEntityUtils.copyNbtData(tile);
+ net.minecraft.nbt.CompoundTag tag = tile.saveWithId(getWorld().registryAccess());
return getBlock(position).toBaseBlock(
LazyReference.from(() -> NBTConverter.fromNative(tag))
);
@@ -638,7 +632,7 @@ public int hashCode() {
public boolean equals(Object o) {
if (o == null) {
return false;
- } else if ((o instanceof ForgeWorld other)) {
+ } else if ((o instanceof NeoForgeWorld other)) {
Level otherWorld = other.worldRef.get();
Level thisWorld = worldRef.get();
return otherWorld != null && otherWorld.equals(thisWorld);
@@ -653,22 +647,22 @@ public boolean equals(Object o) {
public List extends Entity> getEntities(Region region) {
final ServerLevel world = getWorld();
AABB box = new AABB(
- ForgeAdapter.toVec3(region.getMinimumPoint()),
- ForgeAdapter.toVec3(region.getMaximumPoint().add(BlockVector3.ONE))
+ NeoForgeAdapter.toVec3(region.getMinimumPoint()),
+ NeoForgeAdapter.toVec3(region.getMaximumPoint().add(BlockVector3.ONE))
);
List nmsEntities = world.getEntities(
(net.minecraft.world.entity.Entity) null,
box,
- e -> region.contains(ForgeAdapter.adapt(e.blockPosition()))
+ e -> region.contains(NeoForgeAdapter.adapt(e.blockPosition()))
);
- return nmsEntities.stream().map(ForgeEntity::new).collect(ImmutableList.toImmutableList());
+ return nmsEntities.stream().map(NeoForgeEntity::new).collect(ImmutableList.toImmutableList());
}
@Override
public List extends Entity> getEntities() {
final ServerLevel world = getWorld();
return Streams.stream(world.getAllEntities())
- .map(ForgeEntity::new)
+ .map(NeoForgeEntity::new)
.collect(ImmutableList.toImmutableList());
}
@@ -697,7 +691,7 @@ public Entity createEntity(Location location, BaseEntity entity) {
});
if (createdEntity != null) {
world.addFreshEntityWithPassengers(createdEntity);
- return new ForgeEntity(createdEntity);
+ return new NeoForgeEntity(createdEntity);
}
return null;
}
@@ -722,13 +716,7 @@ public Mask createLiquidMask() {
return new AbstractExtentMask(this) {
@Override
public boolean test(BlockVector3 vector) {
- return ForgeAdapter.adapt(getExtent().getBlock(vector)).getBlock() instanceof LiquidBlock;
- }
-
- @Nullable
- @Override
- public Mask2D toMask2D() {
- return null;
+ return NeoForgeAdapter.adapt(getExtent().getBlock(vector)).getBlock() instanceof LiquidBlock;
}
};
}
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWorldEdit.java
similarity index 75%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWorldEdit.java
index 18fb444a5a..4cd46b2121 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWorldEdit.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge;
+package com.sk89q.worldedit.neoforge;
import com.mojang.brigadier.ParseResults;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
@@ -31,10 +31,10 @@
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extension.platform.PlatformManager;
-import com.sk89q.worldedit.forge.net.handler.WECUIPacketHandler;
import com.sk89q.worldedit.internal.anvil.ChunkDeleter;
import com.sk89q.worldedit.internal.event.InteractionDebouncer;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
+import com.sk89q.worldedit.neoforge.net.handler.WECUIPacketHandler;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeCategory;
@@ -51,6 +51,7 @@
import net.minecraft.core.Holder;
import net.minecraft.core.HolderSet;
import net.minecraft.core.Registry;
+import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
@@ -60,90 +61,69 @@
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.biome.Biome;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.event.CommandEvent;
-import net.minecraftforge.event.RegisterCommandsEvent;
-import net.minecraftforge.event.entity.player.PlayerEvent;
-import net.minecraftforge.event.entity.player.PlayerInteractEvent;
-import net.minecraftforge.event.server.ServerAboutToStartEvent;
-import net.minecraftforge.event.server.ServerStartedEvent;
-import net.minecraftforge.event.server.ServerStoppingEvent;
-import net.minecraftforge.eventbus.api.Event;
-import net.minecraftforge.eventbus.api.IEventBus;
-import net.minecraftforge.eventbus.api.SubscribeEvent;
-import net.minecraftforge.fml.IExtensionPoint;
-import net.minecraftforge.fml.ModContainer;
-import net.minecraftforge.fml.ModLoadingContext;
-import net.minecraftforge.fml.common.Mod;
-import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
-import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
-import net.minecraftforge.fml.loading.FMLPaths;
-import net.minecraftforge.registries.ForgeRegistries;
+import net.neoforged.bus.api.Event;
+import net.neoforged.bus.api.IEventBus;
+import net.neoforged.bus.api.SubscribeEvent;
+import net.neoforged.fml.ModContainer;
+import net.neoforged.fml.ModLoadingContext;
+import net.neoforged.fml.common.Mod;
+import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
+import net.neoforged.fml.loading.FMLPaths;
+import net.neoforged.neoforge.common.NeoForge;
+import net.neoforged.neoforge.event.CommandEvent;
+import net.neoforged.neoforge.event.RegisterCommandsEvent;
+import net.neoforged.neoforge.event.entity.player.PlayerEvent;
+import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
+import net.neoforged.neoforge.event.server.ServerAboutToStartEvent;
+import net.neoforged.neoforge.event.server.ServerStartedEvent;
+import net.neoforged.neoforge.event.server.ServerStoppingEvent;
import org.apache.logging.log4j.Logger;
import org.enginehub.piston.Command;
import java.io.IOException;
import java.io.UncheckedIOException;
-import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Set;
-import java.util.function.Supplier;
import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.sk89q.worldedit.forge.ForgeAdapter.adaptCommandSource;
-import static com.sk89q.worldedit.forge.ForgeAdapter.adaptPlayer;
import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAME;
+import static com.sk89q.worldedit.neoforge.NeoForgeAdapter.adaptCommandSource;
+import static com.sk89q.worldedit.neoforge.NeoForgeAdapter.adaptPlayer;
/**
* The Forge implementation of WorldEdit.
*/
-@Mod(ForgeWorldEdit.MOD_ID)
-public class ForgeWorldEdit {
+@Mod(NeoForgeWorldEdit.MOD_ID)
+public class NeoForgeWorldEdit {
private static final Logger LOGGER = LogManagerCompat.getLogger();
public static final String MOD_ID = "worldedit";
public static final String CUI_PLUGIN_CHANNEL = "cui";
- private ForgePermissionsProvider provider;
+ private NeoForgePermissionsProvider provider;
- public static ForgeWorldEdit inst;
+ public static NeoForgeWorldEdit inst;
private InteractionDebouncer debouncer;
- private ForgePlatform platform;
- private ForgeConfiguration config;
+ private NeoForgePlatform platform;
+ private NeoForgeConfiguration config;
private Path workingDir;
private ModContainer container;
- public ForgeWorldEdit() {
+ public NeoForgeWorldEdit(IEventBus modBus) {
inst = this;
- IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
modBus.addListener(this::init);
+ modBus.register(WECUIPacketHandler.class);
- MinecraftForge.EVENT_BUS.register(ThreadSafeCache.getInstance());
- MinecraftForge.EVENT_BUS.register(this);
-
- // Mark WorldEdit as only required on the server
- try {
- // TODO compile under --release 16 and call this normally in 7.3.0
- ModLoadingContext.class.getDeclaredMethod("registerExtensionPoint", Class.class, Supplier.class)
- .invoke(
- ModLoadingContext.get(),
- IExtensionPoint.DisplayTest.class,
- (Supplier>) () -> new IExtensionPoint.DisplayTest(
- () -> IExtensionPoint.DisplayTest.IGNORESERVERONLY,
- (a, b) -> true
- )
- );
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- throw new IllegalStateException(e);
- }
+ NeoForge.EVENT_BUS.register(ThreadSafeCache.getInstance());
+ NeoForge.EVENT_BUS.register(this);
}
private void init(FMLCommonSetupEvent event) {
@@ -161,42 +141,36 @@ private void init(FMLCommonSetupEvent event) {
setupPlatform();
- WECUIPacketHandler.init();
-
- LOGGER.info("WorldEdit for Forge (version " + getInternalVersion() + ") is loaded");
+ LOGGER.info("WorldEdit for NeoForge (version {}) is loaded", getInternalVersion());
}
private void setupPlatform() {
- this.platform = new ForgePlatform(this);
+ this.platform = new NeoForgePlatform(this);
debouncer = new InteractionDebouncer(platform);
WorldEdit.getInstance().getPlatformManager().register(platform);
- config = new ForgeConfiguration(this);
+ config = new NeoForgeConfiguration(this);
- // TODO if (ModList.get().isLoaded("sponge")) {
- // this.provider = new ForgePermissionsProvider.SpongePermissionsProvider();
- // } else {
- this.provider = new ForgePermissionsProvider.VanillaPermissionsProvider(platform);
- // }
+ this.provider = new NeoForgePermissionsProvider.VanillaPermissionsProvider(platform);
}
private void setupRegistries(MinecraftServer server) {
// Blocks
- for (ResourceLocation name : ForgeRegistries.BLOCKS.getKeys()) {
+ for (ResourceLocation name : BuiltInRegistries.BLOCK.keySet()) {
if (BlockType.REGISTRY.get(name.toString()) == null) {
BlockType.REGISTRY.register(name.toString(), new BlockType(name.toString(),
- input -> ForgeAdapter.adapt(ForgeAdapter.adapt(input.getBlockType()).defaultBlockState())));
+ input -> NeoForgeAdapter.adapt(NeoForgeAdapter.adapt(input.getBlockType()).defaultBlockState())));
}
}
// Items
- for (ResourceLocation name : ForgeRegistries.ITEMS.getKeys()) {
+ for (ResourceLocation name : BuiltInRegistries.ITEM.keySet()) {
if (ItemType.REGISTRY.get(name.toString()) == null) {
ItemType.REGISTRY.register(name.toString(), new ItemType(name.toString()));
}
}
// Entities
- for (ResourceLocation name : ForgeRegistries.ENTITY_TYPES.getKeys()) {
+ for (ResourceLocation name : BuiltInRegistries.ENTITY_TYPE.keySet()) {
if (EntityType.REGISTRY.get(name.toString()) == null) {
EntityType.REGISTRY.register(name.toString(), new EntityType(name.toString()));
}
@@ -228,19 +202,19 @@ private void setupRegistries(MinecraftServer server) {
.stream()
.flatMap(HolderSet.Named::stream)
.map(Holder::value)
- .map(ForgeAdapter::adapt)
+ .map(NeoForgeAdapter::adapt)
.collect(Collectors.toSet()))
);
}
});
// Features
- for (ResourceLocation name: server.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).keySet()) {
+ for (ResourceLocation name : server.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).keySet()) {
if (ConfiguredFeatureType.REGISTRY.get(name.toString()) == null) {
ConfiguredFeatureType.REGISTRY.register(name.toString(), new ConfiguredFeatureType(name.toString()));
}
}
// Structures
- for (ResourceLocation name: server.registryAccess().registryOrThrow(Registries.STRUCTURE).keySet()) {
+ for (ResourceLocation name : server.registryAccess().registryOrThrow(Registries.STRUCTURE).keySet()) {
if (StructureType.REGISTRY.get(name.toString()) == null) {
StructureType.REGISTRY.register(name.toString(), new StructureType(name.toString()));
}
@@ -310,9 +284,9 @@ public void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event) {
ServerPlayer playerEntity = (ServerPlayer) event.getEntity();
WorldEdit we = WorldEdit.getInstance();
- ForgePlayer player = adaptPlayer(playerEntity);
- ForgeWorld world = getWorld((ServerLevel) playerEntity.level());
- Direction direction = ForgeAdapter.adaptEnumFacing(event.getFace());
+ NeoForgePlayer player = adaptPlayer(playerEntity);
+ NeoForgeWorld world = getWorld((ServerLevel) playerEntity.level());
+ Direction direction = NeoForgeAdapter.adaptEnumFacing(event.getFace());
BlockPos blockPos = event.getPos();
Location pos = new Location(world, blockPos.getX(), blockPos.getY(), blockPos.getZ());
@@ -333,9 +307,9 @@ public void onRightClickBlock(PlayerInteractEvent.RightClickBlock event) {
ServerPlayer playerEntity = (ServerPlayer) event.getEntity();
WorldEdit we = WorldEdit.getInstance();
- ForgePlayer player = adaptPlayer(playerEntity);
- ForgeWorld world = getWorld((ServerLevel) playerEntity.level());
- Direction direction = ForgeAdapter.adaptEnumFacing(event.getFace());
+ NeoForgePlayer player = adaptPlayer(playerEntity);
+ NeoForgeWorld world = getWorld((ServerLevel) playerEntity.level());
+ Direction direction = NeoForgeAdapter.adaptEnumFacing(event.getFace());
BlockPos blockPos = event.getPos();
Location pos = new Location(world, blockPos.getX(), blockPos.getY(), blockPos.getZ());
@@ -354,7 +328,7 @@ public void onLeftClickAir(ServerPlayer playerEntity, InteractionHand hand) {
}
WorldEdit we = WorldEdit.getInstance();
- ForgePlayer player = adaptPlayer(playerEntity);
+ NeoForgePlayer player = adaptPlayer(playerEntity);
Optional previousResult = debouncer.getDuplicateInteractionResult(player);
if (previousResult.isPresent()) {
@@ -373,7 +347,7 @@ public void onRightClickItem(PlayerInteractEvent.RightClickItem event) {
ServerPlayer playerEntity = (ServerPlayer) event.getEntity();
WorldEdit we = WorldEdit.getInstance();
- ForgePlayer player = adaptPlayer(playerEntity);
+ NeoForgePlayer player = adaptPlayer(playerEntity);
Optional previousResult = debouncer.getDuplicateInteractionResult(player);
if (previousResult.isPresent()) {
@@ -413,7 +387,7 @@ public void onPlayerLogOut(PlayerEvent.PlayerLoggedOutEvent event) {
debouncer.clearInteraction(adaptPlayer(player));
WorldEdit.getInstance().getEventBus()
- .post(new SessionIdleEvent(new ForgePlayer.SessionKeyImpl(player)));
+ .post(new SessionIdleEvent(new NeoForgePlayer.SessionKeyImpl(player)));
}
}
@@ -422,7 +396,7 @@ public void onPlayerLogOut(PlayerEvent.PlayerLoggedOutEvent event) {
*
* @return the Forge configuration
*/
- ForgeConfiguration getConfig() {
+ NeoForgeConfiguration getConfig() {
return this.config;
}
@@ -443,9 +417,9 @@ public LocalSession getSession(ServerPlayer player) {
* @param world the world
* @return the WorldEdit world
*/
- public ForgeWorld getWorld(ServerLevel world) {
+ public NeoForgeWorld getWorld(ServerLevel world) {
checkNotNull(world);
- return new ForgeWorld(world);
+ return new NeoForgeWorld(world);
}
/**
@@ -475,11 +449,11 @@ String getInternalVersion() {
return container.getModInfo().getVersion().toString();
}
- public void setPermissionsProvider(ForgePermissionsProvider provider) {
+ public void setPermissionsProvider(NeoForgePermissionsProvider provider) {
this.provider = provider;
}
- public ForgePermissionsProvider getPermissionsProvider() {
+ public NeoForgePermissionsProvider getPermissionsProvider() {
return provider;
}
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/ThreadSafeCache.java
similarity index 87%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/ThreadSafeCache.java
index da457b4b9a..9fae482670 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/ThreadSafeCache.java
@@ -17,13 +17,13 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge;
+package com.sk89q.worldedit.neoforge;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
-import net.minecraftforge.event.TickEvent;
-import net.minecraftforge.eventbus.api.SubscribeEvent;
-import net.minecraftforge.server.ServerLifecycleHooks;
+import net.neoforged.bus.api.SubscribeEvent;
+import net.neoforged.neoforge.event.TickEvent;
+import net.neoforged.neoforge.server.ServerLifecycleHooks;
import java.util.Collections;
import java.util.HashSet;
@@ -51,7 +51,11 @@ public Set getOnlineIds() {
}
@SubscribeEvent
- public void tickStart(TickEvent event) {
+ public void tickStart(TickEvent.ServerTickEvent event) {
+ if (event.phase != TickEvent.Phase.END) {
+ return;
+ }
+
long now = System.currentTimeMillis();
if (now - lastRefresh > REFRESH_DELAY) {
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/WorldEditFakePlayer.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/WorldEditFakePlayer.java
similarity index 98%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/WorldEditFakePlayer.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/WorldEditFakePlayer.java
index 277ffd28a5..3940f6198b 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/WorldEditFakePlayer.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/WorldEditFakePlayer.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge;
+package com.sk89q.worldedit.neoforge;
import com.mojang.authlib.GameProfile;
import net.minecraft.network.chat.Component;
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/WorldEditGenListener.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/WorldEditGenListener.java
similarity index 85%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/WorldEditGenListener.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/WorldEditGenListener.java
index 2904fea2f0..5051cc6ae4 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/WorldEditGenListener.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/WorldEditGenListener.java
@@ -17,13 +17,11 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge;
+package com.sk89q.worldedit.neoforge;
import net.minecraft.server.level.progress.ChunkProgressListener;
import net.minecraft.world.level.ChunkPos;
-import net.minecraft.world.level.chunk.ChunkStatus;
-
-import javax.annotation.Nullable;
+import net.minecraft.world.level.chunk.status.ChunkStatus;
// For now, this does nothing, but might be useful later for regen progress communication.
class WorldEditGenListener implements ChunkProgressListener {
@@ -32,7 +30,7 @@ public void updateSpawnPos(ChunkPos chunkPos) {
}
@Override
- public void onStatusChange(ChunkPos chunkPos, @Nullable ChunkStatus chunkStatus) {
+ public void onStatusChange(ChunkPos chunkPos, @org.jetbrains.annotations.Nullable ChunkStatus chunkStatus) {
}
@Override
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ExtendedChunk.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/ExtendedChunk.java
similarity index 97%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ExtendedChunk.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/ExtendedChunk.java
index 7fb97026dc..25af031429 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ExtendedChunk.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/ExtendedChunk.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge.internal;
+package com.sk89q.worldedit.neoforge.internal;
import com.sk89q.worldedit.util.SideEffect;
import net.minecraft.core.BlockPos;
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/IPropertyAdapter.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/IPropertyAdapter.java
similarity index 97%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/IPropertyAdapter.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/IPropertyAdapter.java
index e17f673510..2d7d965cd1 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/IPropertyAdapter.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/IPropertyAdapter.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge.internal;
+package com.sk89q.worldedit.neoforge.internal;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.registry.state.Property;
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/NBTConverter.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/NBTConverter.java
similarity index 99%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/NBTConverter.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/NBTConverter.java
index e43058a4a5..25bc7930a9 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/NBTConverter.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/NBTConverter.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge.internal;
+package com.sk89q.worldedit.neoforge.internal;
import org.enginehub.linbus.common.LinTagId;
import org.enginehub.linbus.tree.LinByteArrayTag;
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ForgeEntity.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/NeoForgeEntity.java
similarity index 82%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ForgeEntity.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/NeoForgeEntity.java
index 997994690f..837f6cff6b 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ForgeEntity.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/NeoForgeEntity.java
@@ -17,35 +17,34 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge.internal;
+package com.sk89q.worldedit.neoforge.internal;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.metadata.EntityProperties;
import com.sk89q.worldedit.extent.Extent;
-import com.sk89q.worldedit.forge.ForgeAdapter;
-import com.sk89q.worldedit.forge.ForgeEntityProperties;
-import com.sk89q.worldedit.forge.internal.NBTConverter;
import com.sk89q.worldedit.math.Vector3;
+import com.sk89q.worldedit.neoforge.NeoForgeAdapter;
+import com.sk89q.worldedit.neoforge.NeoForgeEntityProperties;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.world.NullWorld;
import com.sk89q.worldedit.world.entity.EntityTypes;
+import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
-import net.minecraftforge.registries.ForgeRegistries;
import java.lang.ref.WeakReference;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
-public class ForgeEntity implements Entity {
+public class NeoForgeEntity implements Entity {
private final WeakReference entityRef;
- public ForgeEntity(net.minecraft.world.entity.Entity entity) {
+ public NeoForgeEntity(net.minecraft.world.entity.Entity entity) {
checkNotNull(entity);
this.entityRef = new WeakReference<>(entity);
}
@@ -56,10 +55,7 @@ public BaseEntity getState() {
if (entity == null || entity.isPassenger()) {
return null;
}
- ResourceLocation id = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType());
- if (id == null) {
- return null;
- }
+ ResourceLocation id = BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType());
CompoundTag tag = new CompoundTag();
entity.saveWithoutId(tag);
return new BaseEntity(EntityTypes.get(id.toString()), LazyReference.from(() -> NBTConverter.fromNative(tag)));
@@ -73,7 +69,7 @@ public Location getLocation() {
float yaw = entity.getYRot();
float pitch = entity.getXRot();
- return new Location(ForgeAdapter.adapt((ServerLevel) entity.level()), position, yaw, pitch);
+ return new Location(NeoForgeAdapter.adapt((ServerLevel) entity.level()), position, yaw, pitch);
} else {
return new Location(NullWorld.getInstance());
}
@@ -89,7 +85,7 @@ public boolean setLocation(Location location) {
public Extent getExtent() {
net.minecraft.world.entity.Entity entity = entityRef.get();
if (entity != null) {
- return ForgeAdapter.adapt((ServerLevel) entity.level());
+ return NeoForgeAdapter.adapt((ServerLevel) entity.level());
} else {
return NullWorld.getInstance();
}
@@ -111,7 +107,7 @@ public T getFacet(Class extends T> cls) {
net.minecraft.world.entity.Entity entity = entityRef.get();
if (entity != null) {
if (EntityProperties.class.isAssignableFrom(cls)) {
- return (T) new ForgeEntityProperties(entity);
+ return (T) new NeoForgeEntityProperties(entity);
} else {
return null;
}
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ForgeServerLevelDelegateProxy.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/NeoForgeServerLevelDelegateProxy.java
similarity index 78%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ForgeServerLevelDelegateProxy.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/NeoForgeServerLevelDelegateProxy.java
index 809570e1de..64266c1663 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ForgeServerLevelDelegateProxy.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/NeoForgeServerLevelDelegateProxy.java
@@ -17,13 +17,13 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge.internal;
+package com.sk89q.worldedit.neoforge.internal;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.entity.BaseEntity;
-import com.sk89q.worldedit.forge.ForgeAdapter;
import com.sk89q.worldedit.math.Vector3;
+import com.sk89q.worldedit.neoforge.NeoForgeAdapter;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.block.BlockTypes;
import net.minecraft.core.BlockPos;
@@ -38,12 +38,12 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-public class ForgeServerLevelDelegateProxy implements InvocationHandler {
+public class NeoForgeServerLevelDelegateProxy implements InvocationHandler {
private final EditSession editSession;
private final ServerLevel serverLevel;
- private ForgeServerLevelDelegateProxy(EditSession editSession, ServerLevel serverLevel) {
+ private NeoForgeServerLevelDelegateProxy(EditSession editSession, ServerLevel serverLevel) {
this.editSession = editSession;
this.serverLevel = serverLevel;
}
@@ -52,7 +52,7 @@ public static WorldGenLevel newInstance(EditSession editSession, ServerLevel ser
return (WorldGenLevel) Proxy.newProxyInstance(
serverLevel.getClass().getClassLoader(),
serverLevel.getClass().getInterfaces(),
- new ForgeServerLevelDelegateProxy(editSession, serverLevel)
+ new NeoForgeServerLevelDelegateProxy(editSession, serverLevel)
);
}
@@ -63,18 +63,23 @@ private BlockEntity getBlockEntity(BlockPos blockPos) {
return null;
}
BlockEntity newEntity = tileEntity.getType().create(blockPos, getBlockState(blockPos));
- newEntity.load(NBTConverter.toNative(this.editSession.getFullBlock(ForgeAdapter.adapt(blockPos)).getNbtReference().getValue()));
+ newEntity.loadWithComponents(
+ NBTConverter.toNative(
+ this.editSession.getFullBlock(NeoForgeAdapter.adapt(blockPos)).getNbtReference().getValue()
+ ),
+ this.serverLevel.registryAccess()
+ );
return newEntity;
}
private BlockState getBlockState(BlockPos blockPos) {
- return ForgeAdapter.adapt(this.editSession.getBlock(ForgeAdapter.adapt(blockPos)));
+ return NeoForgeAdapter.adapt(this.editSession.getBlock(NeoForgeAdapter.adapt(blockPos)));
}
private boolean setBlock(BlockPos blockPos, BlockState blockState) {
try {
- return editSession.setBlock(ForgeAdapter.adapt(blockPos), ForgeAdapter.adapt(blockState));
+ return editSession.setBlock(NeoForgeAdapter.adapt(blockPos), NeoForgeAdapter.adapt(blockState));
} catch (MaxChangedBlocksException e) {
throw new RuntimeException(e);
}
@@ -82,16 +87,16 @@ private boolean setBlock(BlockPos blockPos, BlockState blockState) {
private boolean removeBlock(BlockPos blockPos, boolean bl) {
try {
- return editSession.setBlock(ForgeAdapter.adapt(blockPos), BlockTypes.AIR.getDefaultState());
+ return editSession.setBlock(NeoForgeAdapter.adapt(blockPos), BlockTypes.AIR.getDefaultState());
} catch (MaxChangedBlocksException e) {
throw new RuntimeException(e);
}
}
private boolean addEntity(Entity entity) {
- Vector3 pos = ForgeAdapter.adapt(entity.getPosition(0.0f));
- Location location = new Location(ForgeAdapter.adapt(serverLevel), pos.x(), pos.y(), pos.z());
- BaseEntity baseEntity = new ForgeEntity(entity).getState();
+ Vector3 pos = NeoForgeAdapter.adapt(entity.getPosition(0.0f));
+ Location location = new Location(NeoForgeAdapter.adapt(serverLevel), pos.x(), pos.y(), pos.z());
+ BaseEntity baseEntity = new NeoForgeEntity(entity).getState();
return editSession.createEntity(location, baseEntity) != null;
}
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ForgeTransmogrifier.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/NeoForgeTransmogrifier.java
similarity index 92%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ForgeTransmogrifier.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/NeoForgeTransmogrifier.java
index 38224711fd..c835ae1ae8 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ForgeTransmogrifier.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/NeoForgeTransmogrifier.java
@@ -17,13 +17,13 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge.internal;
+package com.sk89q.worldedit.neoforge.internal;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList;
-import com.sk89q.worldedit.forge.ForgeAdapter;
+import com.sk89q.worldedit.neoforge.NeoForgeAdapter;
import com.sk89q.worldedit.registry.state.BooleanProperty;
import com.sk89q.worldedit.registry.state.DirectionalProperty;
import com.sk89q.worldedit.registry.state.EnumProperty;
@@ -45,7 +45,7 @@
/**
* Raw, un-cached transformations.
*/
-public class ForgeTransmogrifier {
+public class NeoForgeTransmogrifier {
private static final LoadingCache, Property>> PROPERTY_CACHE = CacheBuilder.newBuilder().build(new CacheLoader<>() {
@Override
@@ -58,7 +58,7 @@ public Property> load(net.minecraft.world.level.block.state.properties.Propert
}
if (property instanceof DirectionProperty) {
return new DirectionalProperty(property.getName(), ((DirectionProperty) property).getPossibleValues().stream()
- .map(ForgeAdapter::adaptEnumFacing)
+ .map(NeoForgeAdapter::adaptEnumFacing)
.collect(Collectors.toList()));
}
if (property instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
@@ -82,7 +82,7 @@ public static Map, Object> transmogToWorldEditProperties(BlockType b
for (Map.Entry, Comparable>> prop : mcProps.entrySet()) {
Object value = prop.getValue();
if (prop.getKey() instanceof DirectionProperty) {
- value = ForgeAdapter.adaptEnumFacing((net.minecraft.core.Direction) value);
+ value = NeoForgeAdapter.adaptEnumFacing((net.minecraft.core.Direction) value);
} else if (prop.getKey() instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
value = ((StringRepresentable) value).getSerializedName();
}
@@ -99,7 +99,7 @@ private static net.minecraft.world.level.block.state.BlockState transmogToMinecr
// we may need to adapt this value, depending on the source prop
if (property instanceof DirectionProperty) {
Direction dir = (Direction) value;
- value = ForgeAdapter.adapt(dir);
+ value = NeoForgeAdapter.adapt(dir);
} else if (property instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
String enumName = (String) value;
value = ((net.minecraft.world.level.block.state.properties.EnumProperty>) property).getValue((String) value)
@@ -112,17 +112,17 @@ private static net.minecraft.world.level.block.state.BlockState transmogToMinecr
}
public static net.minecraft.world.level.block.state.BlockState transmogToMinecraft(BlockState blockState) {
- Block mcBlock = ForgeAdapter.adapt(blockState.getBlockType());
+ Block mcBlock = NeoForgeAdapter.adapt(blockState.getBlockType());
net.minecraft.world.level.block.state.BlockState newState = mcBlock.defaultBlockState();
Map, Object> states = blockState.getStates();
return transmogToMinecraftProperties(mcBlock.getStateDefinition(), newState, states);
}
public static BlockState transmogToWorldEdit(net.minecraft.world.level.block.state.BlockState blockState) {
- BlockType blockType = ForgeAdapter.adapt(blockState.getBlock());
+ BlockType blockType = NeoForgeAdapter.adapt(blockState.getBlock());
return blockType.getState(transmogToWorldEditProperties(blockType, blockState.getValues()));
}
- private ForgeTransmogrifier() {
+ private NeoForgeTransmogrifier() {
}
}
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ForgeWorldNativeAccess.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/NeoForgeWorldNativeAccess.java
similarity index 88%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ForgeWorldNativeAccess.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/NeoForgeWorldNativeAccess.java
index 2eabc39a66..c1e98765bf 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ForgeWorldNativeAccess.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal/NeoForgeWorldNativeAccess.java
@@ -17,17 +17,19 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge.internal;
+package com.sk89q.worldedit.neoforge.internal;
-import com.sk89q.worldedit.forge.ForgeAdapter;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
+import com.sk89q.worldedit.neoforge.NeoForgeAdapter;
import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.util.SideEffectSet;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.FullChunkStatus;
import net.minecraft.server.level.ServerLevel;
+import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk;
import org.enginehub.linbus.tree.LinCompoundTag;
@@ -36,14 +38,14 @@
import java.util.Objects;
import javax.annotation.Nullable;
-public class ForgeWorldNativeAccess implements WorldNativeAccess {
+public class NeoForgeWorldNativeAccess implements WorldNativeAccess {
private static final int UPDATE = 1;
private static final int NOTIFY = 2;
private final WeakReference world;
private SideEffectSet sideEffectSet;
- public ForgeWorldNativeAccess(WeakReference world) {
+ public NeoForgeWorldNativeAccess(WeakReference world) {
this.world = world;
}
@@ -66,7 +68,7 @@ public BlockState toNative(com.sk89q.worldedit.world.block.BlockState state) {
int stateId = BlockStateIdAccess.getBlockStateId(state);
return BlockStateIdAccess.isValidInternalId(stateId)
? Block.stateById(stateId)
- : ForgeAdapter.adapt(state);
+ : NeoForgeAdapter.adapt(state);
}
@Override
@@ -103,7 +105,14 @@ public void updateLightingForBlock(BlockPos position) {
@Override
public boolean updateTileEntity(BlockPos position, LinCompoundTag tag) {
net.minecraft.nbt.CompoundTag nativeTag = NBTConverter.toNative(tag);
- return TileEntityUtils.setTileEntity(getWorld(), position, nativeTag);
+ Level level = getWorld();
+ BlockEntity tileEntity = level.getChunkAt(position).getBlockEntity(position);
+ if (tileEntity == null) {
+ return false;
+ }
+ tileEntity.loadWithComponents(nativeTag, level.registryAccess());
+ tileEntity.setChanged();
+ return true;
}
@Override
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/mixin/AccessorServerPlayerGameMode.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/mixin/AccessorServerPlayerGameMode.java
similarity index 96%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/mixin/AccessorServerPlayerGameMode.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/mixin/AccessorServerPlayerGameMode.java
index 5bb01abe28..234799dc28 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/mixin/AccessorServerPlayerGameMode.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/mixin/AccessorServerPlayerGameMode.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge.mixin;
+package com.sk89q.worldedit.neoforge.mixin;
import net.minecraft.server.level.ServerPlayerGameMode;
import org.spongepowered.asm.mixin.Mixin;
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/mixin/MixinLevelChunkSetBlockHook.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/mixin/MixinLevelChunkSetBlockHook.java
similarity index 97%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/mixin/MixinLevelChunkSetBlockHook.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/mixin/MixinLevelChunkSetBlockHook.java
index 4bfa690b3b..e4bb66b6bf 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/mixin/MixinLevelChunkSetBlockHook.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/mixin/MixinLevelChunkSetBlockHook.java
@@ -17,9 +17,9 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge.mixin;
+package com.sk89q.worldedit.neoforge.mixin;
-import com.sk89q.worldedit.forge.internal.ExtendedChunk;
+import com.sk89q.worldedit.neoforge.internal.ExtendedChunk;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.server.MinecraftServer;
diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/mixin/MixinServerGamePacketListenerImpl.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/mixin/MixinServerGamePacketListenerImpl.java
similarity index 87%
rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/mixin/MixinServerGamePacketListenerImpl.java
rename to worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/mixin/MixinServerGamePacketListenerImpl.java
index de559a823e..fd9754373f 100644
--- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/mixin/MixinServerGamePacketListenerImpl.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/mixin/MixinServerGamePacketListenerImpl.java
@@ -17,15 +17,16 @@
* along with this program. If not, see .
*/
-package com.sk89q.worldedit.forge.mixin;
+package com.sk89q.worldedit.neoforge.mixin;
-import com.sk89q.worldedit.forge.ForgeWorldEdit;
+import com.sk89q.worldedit.neoforge.NeoForgeWorldEdit;
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
import net.minecraft.network.protocol.game.ServerboundSwingPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -35,6 +36,7 @@ public class MixinServerGamePacketListenerImpl {
@Shadow
public ServerPlayer player;
+ @Unique
private int ignoreSwingPackets;
@Inject(method = "handleAnimate", at = @At("HEAD"))
@@ -42,8 +44,8 @@ private void onAnimate(ServerboundSwingPacket packet, CallbackInfo ci) {
if (!((AccessorServerPlayerGameMode) this.player.gameMode).isDestroyingBlock()) {
if (this.ignoreSwingPackets > 0) {
this.ignoreSwingPackets--;
- } else if (ForgeWorldEdit.inst != null) {
- ForgeWorldEdit.inst.onLeftClickAir(this.player, packet.getHand());
+ } else if (NeoForgeWorldEdit.inst != null) {
+ NeoForgeWorldEdit.inst.onLeftClickAir(this.player, packet.getHand());
}
}
}
diff --git a/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/net/handler/WECUIPacketHandler.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/net/handler/WECUIPacketHandler.java
new file mode 100644
index 0000000000..4085bd5a8d
--- /dev/null
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/net/handler/WECUIPacketHandler.java
@@ -0,0 +1,73 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.neoforge.net.handler;
+
+import com.sk89q.worldedit.LocalSession;
+import com.sk89q.worldedit.neoforge.NeoForgeAdapter;
+import com.sk89q.worldedit.neoforge.NeoForgePlayer;
+import com.sk89q.worldedit.neoforge.NeoForgeWorldEdit;
+import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.level.ServerPlayer;
+import net.neoforged.bus.api.SubscribeEvent;
+import net.neoforged.fml.common.EventBusSubscriber;
+import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
+
+import java.nio.charset.StandardCharsets;
+
+public final class WECUIPacketHandler {
+ private WECUIPacketHandler() {
+ }
+
+ private static final String PROTOCOL_VERSION = "1";
+
+ public static final ResourceLocation CUI_IDENTIFIER = new ResourceLocation(NeoForgeWorldEdit.MOD_ID, NeoForgeWorldEdit.CUI_PLUGIN_CHANNEL);
+
+ public record CuiPacket(String text) implements CustomPacketPayload {
+ public static final Type TYPE = new Type<>(CUI_IDENTIFIER);
+
+ @Override
+ public Type extends CustomPacketPayload> type() {
+ return TYPE;
+ }
+ }
+
+ @SubscribeEvent
+ public static void register(RegisterPayloadHandlersEvent event) {
+ event.registrar(PROTOCOL_VERSION)
+ .playBidirectional(
+ CuiPacket.TYPE,
+ CustomPacketPayload.codec(
+ (packet, buffer) -> buffer.writeCharSequence(packet.text(), StandardCharsets.UTF_8),
+ buffer -> new CuiPacket(buffer.toString(StandardCharsets.UTF_8))
+ ),
+ (payload, context) -> {
+ if (!(context.player() instanceof ServerPlayer player)) {
+ // Client-side packet, ignore (this is for WECUI to handle)
+ return;
+ }
+ LocalSession session = NeoForgeWorldEdit.inst.getSession(player);
+ NeoForgePlayer actor = NeoForgeAdapter.adaptPlayer(player);
+ session.handleCUIInitializationMessage(payload.text(), actor);
+ }
+ );
+ }
+
+}
diff --git a/worldedit-neoforge/src/main/resources/META-INF/accesstransformer.cfg b/worldedit-neoforge/src/main/resources/META-INF/accesstransformer.cfg
new file mode 100644
index 0000000000..08401db51c
--- /dev/null
+++ b/worldedit-neoforge/src/main/resources/META-INF/accesstransformer.cfg
@@ -0,0 +1,10 @@
+public net.minecraft.server.MinecraftServer nextTickTimeNanos
+
+# For regen
+public net.minecraft.server.MinecraftServer storageSource
+public net.minecraft.server.level.ServerChunkCache mainThreadProcessor
+
+public net.minecraft.world.level.chunk.ChunkBiomeContainer biomes
+public-f net.minecraft.world.level.storage.PrimaryLevelData worldOptions
+
+public net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket (Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntityType;Lnet/minecraft/nbt/CompoundTag;)V
diff --git a/worldedit-neoforge/src/main/resources/META-INF/neoforge.mods.toml b/worldedit-neoforge/src/main/resources/META-INF/neoforge.mods.toml
new file mode 100644
index 0000000000..0f42fe20dd
--- /dev/null
+++ b/worldedit-neoforge/src/main/resources/META-INF/neoforge.mods.toml
@@ -0,0 +1,36 @@
+modLoader = "javafml"
+loaderVersion = "[3,)"
+issueTrackerURL = "https://discord.gg/enginehub"
+license = "GPLv3"
+
+[[mods]]
+modId = "worldedit"
+version = "${version}"
+displayName = "WorldEdit"
+displayURL = "https://enginehub.org/worldedit/"
+description = '''
+WorldEdit is an easy-to-use in-game world editor for Minecraft, supporting both single- and multi-player.
+'''
+authors = "EngineHub"
+logoFile = "worldedit-icon.png"
+displayTest = "IGNORE_SERVER_VERSION"
+
+[[mixins]]
+config = "worldedit-neoforge.mixins.json"
+
+[[accessTransformers]]
+file = "META-INF/accesstransformer.cfg"
+
+[[dependencies.worldedit]]
+modId = "minecraft"
+type = "required"
+versionRange = "[${minecraftVersion},${nextMajorMinecraftVersion})"
+ordering = "NONE"
+side = "BOTH"
+
+[[dependencies.worldedit]]
+modId = "neoforge"
+type = "required"
+versionRange = "[${neoVersion},)"
+ordering = "NONE"
+side = "BOTH"
diff --git a/worldedit-forge/src/main/resources/defaults/worldedit.properties b/worldedit-neoforge/src/main/resources/defaults/worldedit.properties
similarity index 100%
rename from worldedit-forge/src/main/resources/defaults/worldedit.properties
rename to worldedit-neoforge/src/main/resources/defaults/worldedit.properties
diff --git a/worldedit-forge/src/main/resources/pack.mcmeta b/worldedit-neoforge/src/main/resources/pack.mcmeta
similarity index 100%
rename from worldedit-forge/src/main/resources/pack.mcmeta
rename to worldedit-neoforge/src/main/resources/pack.mcmeta
diff --git a/worldedit-forge/src/main/resources/worldedit-icon.png b/worldedit-neoforge/src/main/resources/worldedit-icon.png
similarity index 100%
rename from worldedit-forge/src/main/resources/worldedit-icon.png
rename to worldedit-neoforge/src/main/resources/worldedit-icon.png
diff --git a/worldedit-forge/src/main/resources/worldedit-forge.mixins.json b/worldedit-neoforge/src/main/resources/worldedit-neoforge.mixins.json
similarity index 72%
rename from worldedit-forge/src/main/resources/worldedit-forge.mixins.json
rename to worldedit-neoforge/src/main/resources/worldedit-neoforge.mixins.json
index d7de4e1d3f..b807508229 100644
--- a/worldedit-forge/src/main/resources/worldedit-forge.mixins.json
+++ b/worldedit-neoforge/src/main/resources/worldedit-neoforge.mixins.json
@@ -1,6 +1,6 @@
{
"required": true,
- "package": "com.sk89q.worldedit.forge.mixin",
+ "package": "com.sk89q.worldedit.neoforge.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"AccessorServerPlayerGameMode",
@@ -12,5 +12,5 @@
"injectors": {
"defaultRequire": 1
},
- "refmap": "worldedit-forge.mixins.refmap.json"
+ "refmap": "worldedit-neoforge.mixins.refmap.json"
}
From 6ea5c134505a7d91753872ff8e38e53220fb00d6 Mon Sep 17 00:00:00 2001
From: Octavia Togami
Date: Wed, 24 Apr 2024 01:20:02 -0700
Subject: [PATCH 07/21] [Fabric] Rename CuiPacket to make more sense
---
.../sk89q/worldedit/fabric/FabricPlayer.java | 2 +-
.../fabric/net/handler/WECUIPacketHandler.java | 17 ++++++++++++-----
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java
index 52f512756a..8820c5ad31 100644
--- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java
+++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java
@@ -130,7 +130,7 @@ public void dispatchCUIEvent(CUIEvent event) {
}
ServerPlayNetworking.send(
this.player,
- new WECUIPacketHandler.CuiInitializationPacket(send)
+ new WECUIPacketHandler.CuiPacket(send)
);
}
diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/net/handler/WECUIPacketHandler.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/net/handler/WECUIPacketHandler.java
index 5a78b532d5..4fde51da81 100644
--- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/net/handler/WECUIPacketHandler.java
+++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/net/handler/WECUIPacketHandler.java
@@ -36,8 +36,8 @@ private WECUIPacketHandler() {
public static final ResourceLocation CUI_IDENTIFIER = new ResourceLocation(FabricWorldEdit.MOD_ID, FabricWorldEdit.CUI_PLUGIN_CHANNEL);
- public record CuiInitializationPacket(String text) implements CustomPacketPayload {
- public static final Type TYPE = new Type<>(CUI_IDENTIFIER);
+ public record CuiPacket(String text) implements CustomPacketPayload {
+ public static final Type TYPE = new Type<>(CUI_IDENTIFIER);
@Override
public Type extends CustomPacketPayload> type() {
@@ -47,13 +47,20 @@ public Type extends CustomPacketPayload> type() {
public static void init() {
PayloadTypeRegistry.playC2S().register(
- CuiInitializationPacket.TYPE,
+ CuiPacket.TYPE,
CustomPacketPayload.codec(
(packet, buffer) -> buffer.writeCharSequence(packet.text(), StandardCharsets.UTF_8),
- buffer -> new CuiInitializationPacket(buffer.toString(StandardCharsets.UTF_8))
+ buffer -> new CuiPacket(buffer.toString(StandardCharsets.UTF_8))
)
);
- ServerPlayNetworking.registerGlobalReceiver(CuiInitializationPacket.TYPE, (payload, context) -> {
+ PayloadTypeRegistry.playS2C().register(
+ CuiPacket.TYPE,
+ CustomPacketPayload.codec(
+ (packet, buffer) -> buffer.writeCharSequence(packet.text(), StandardCharsets.UTF_8),
+ buffer -> new CuiPacket(buffer.toString(StandardCharsets.UTF_8))
+ )
+ );
+ ServerPlayNetworking.registerGlobalReceiver(CuiPacket.TYPE, (payload, context) -> {
LocalSession session = FabricWorldEdit.inst.getSession(context.player());
FabricPlayer actor = FabricAdapter.adaptPlayer(context.player());
session.handleCUIInitializationMessage(payload.text(), actor);
From 99319e9ce78ef848746466d91a396f168b4a49b1 Mon Sep 17 00:00:00 2001
From: Octavia Togami
Date: Wed, 24 Apr 2024 02:09:36 -0700
Subject: [PATCH 08/21] Remove unused imports
---
config/checkstyle/checkstyle.xml | 1 +
.../impl/v1_20_R3/PaperweightServerLevelDelegateProxy.java | 2 --
.../com/sk89q/worldedit/bukkit/BukkitBlockCategoryRegistry.java | 2 --
.../java/com/sk89q/worldedit/bukkit/CUIChannelListener.java | 1 -
.../src/main/java/com/sk89q/worldedit/WorldEditManifest.java | 1 -
.../java/com/sk89q/worldedit/command/util/PrintCommandHelp.java | 1 -
.../com/sk89q/worldedit/fabric/FabricBlockCategoryRegistry.java | 1 -
.../java/com/sk89q/worldedit/fabric/internal/FabricEntity.java | 2 --
.../java/com/sk89q/worldedit/neoforge/NeoForgePlatform.java | 2 --
.../worldedit/neoforge/net/handler/WECUIPacketHandler.java | 1 -
10 files changed, 1 insertion(+), 13 deletions(-)
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
index 1a53714503..e3678ec6f4 100644
--- a/config/checkstyle/checkstyle.xml
+++ b/config/checkstyle/checkstyle.xml
@@ -140,6 +140,7 @@ Checks based on Google Checks, modified for EngineHub.
+
diff --git a/worldedit-bukkit/adapters/adapter-1.20.4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R3/PaperweightServerLevelDelegateProxy.java b/worldedit-bukkit/adapters/adapter-1.20.4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R3/PaperweightServerLevelDelegateProxy.java
index 2c9bb5ef34..3cf442e016 100644
--- a/worldedit-bukkit/adapters/adapter-1.20.4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R3/PaperweightServerLevelDelegateProxy.java
+++ b/worldedit-bukkit/adapters/adapter-1.20.4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R3/PaperweightServerLevelDelegateProxy.java
@@ -44,8 +44,6 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.util.Arrays;
-import java.util.stream.Collectors;
public class PaperweightServerLevelDelegateProxy implements InvocationHandler {
diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCategoryRegistry.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCategoryRegistry.java
index 20dede378e..b52b4a74c1 100644
--- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCategoryRegistry.java
+++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCategoryRegistry.java
@@ -30,8 +30,6 @@
import java.util.Set;
import java.util.stream.Collectors;
-import static com.google.common.base.Preconditions.checkNotNull;
-
public class BukkitBlockCategoryRegistry implements BlockCategoryRegistry {
private Set getFromBukkitTag(Tag tag) {
diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java
index 2c6b0f11f7..2488693e91 100644
--- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java
+++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java
@@ -23,7 +23,6 @@
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
-import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
/**
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java
index 2132f727e9..4c0769cbba 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java
@@ -23,7 +23,6 @@
import java.io.UncheckedIOException;
import java.net.JarURLConnection;
import java.net.URI;
-import java.net.URL;
import java.util.function.Supplier;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/PrintCommandHelp.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/PrintCommandHelp.java
index 72eca71bc2..5b4e12e9a6 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/PrintCommandHelp.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/PrintCommandHelp.java
@@ -43,7 +43,6 @@
import static com.sk89q.worldedit.internal.command.CommandUtil.byCleanName;
import static com.sk89q.worldedit.internal.command.CommandUtil.getSubCommands;
-import static java.util.stream.Collectors.toList;
/**
* Implementation of the //help command.
diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricBlockCategoryRegistry.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricBlockCategoryRegistry.java
index 5b50ce7400..d11fd82b99 100644
--- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricBlockCategoryRegistry.java
+++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricBlockCategoryRegistry.java
@@ -23,7 +23,6 @@
import com.sk89q.worldedit.world.registry.BlockCategoryRegistry;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderSet;
-import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/internal/FabricEntity.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/internal/FabricEntity.java
index af8c858490..12db9ce716 100644
--- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/internal/FabricEntity.java
+++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/internal/FabricEntity.java
@@ -33,9 +33,7 @@
import com.sk89q.worldedit.world.entity.EntityTypes;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
-import net.minecraft.nbt.NbtOps;
import net.minecraft.resources.ResourceLocation;
-import org.enginehub.linbus.tree.LinCompoundTag;
import java.lang.ref.WeakReference;
import javax.annotation.Nullable;
diff --git a/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgePlatform.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgePlatform.java
index 5b8a57af1c..9e288e3eb9 100644
--- a/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgePlatform.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgePlatform.java
@@ -59,8 +59,6 @@
import java.util.Set;
import javax.annotation.Nullable;
-import static java.util.stream.Collectors.toList;
-
class NeoForgePlatform extends AbstractPlatform implements MultiUserPlatform {
private final NeoForgeWorldEdit mod;
diff --git a/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/net/handler/WECUIPacketHandler.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/net/handler/WECUIPacketHandler.java
index 4085bd5a8d..1efa18ca8a 100644
--- a/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/net/handler/WECUIPacketHandler.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/net/handler/WECUIPacketHandler.java
@@ -27,7 +27,6 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.neoforged.bus.api.SubscribeEvent;
-import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
import java.nio.charset.StandardCharsets;
From 8ca4876eda17bc69307b444ac60cb8a22ede2ebc Mon Sep 17 00:00:00 2001
From: Octavia Togami
Date: Wed, 24 Apr 2024 02:32:25 -0700
Subject: [PATCH 09/21] Try to tell NG not to go so hard on my CI machines
---
worldedit-neoforge/build.gradle.kts | 3 +++
1 file changed, 3 insertions(+)
diff --git a/worldedit-neoforge/build.gradle.kts b/worldedit-neoforge/build.gradle.kts
index 1354e93514..f52c235e1e 100644
--- a/worldedit-neoforge/build.gradle.kts
+++ b/worldedit-neoforge/build.gradle.kts
@@ -75,6 +75,9 @@ subsystems {
minecraftVersion = "1.20.4"
mappingsVersion = "2024.04.14"
}
+ decompiler {
+ maxMemory("2G")
+ }
}
configure {
From ebb07de9211543cf22c6c3500b50eb971ef84cb4 Mon Sep 17 00:00:00 2001
From: Octavia Togami
Date: Wed, 24 Apr 2024 02:57:18 -0700
Subject: [PATCH 10/21] Adjust memory settings some more to try and make things
work
---
gradle.properties | 2 +-
worldedit-neoforge/build.gradle.kts | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gradle.properties b/gradle.properties
index 8e0e3202bd..d0ac11716d 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,7 +1,7 @@
group=com.sk89q.worldedit
version=7.3.1-SNAPSHOT
-org.gradle.jvmargs=-Xmx2G
+org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true
loom.version=1.6.9
diff --git a/worldedit-neoforge/build.gradle.kts b/worldedit-neoforge/build.gradle.kts
index f52c235e1e..8b3b1f76eb 100644
--- a/worldedit-neoforge/build.gradle.kts
+++ b/worldedit-neoforge/build.gradle.kts
@@ -76,7 +76,7 @@ subsystems {
mappingsVersion = "2024.04.14"
}
decompiler {
- maxMemory("2G")
+ maxMemory("3G")
}
}
From 048cf5e64b6a8d72732f37e1b280d1444a0eba30 Mon Sep 17 00:00:00 2001
From: Madeline Miller
Date: Wed, 24 Apr 2024 20:18:55 +1000
Subject: [PATCH 11/21] Update data from MCUtils
---
.../world/block/BlockCategories.java | 9 ++++
.../worldedit/world/block/BlockTypes.java | 2 +
.../worldedit/world/entity/EntityTypes.java | 4 ++
.../worldedit/world/item/ItemCategories.java | 54 ++++++++++++++++++-
.../sk89q/worldedit/world/item/ItemTypes.java | 21 +++++++-
5 files changed, 87 insertions(+), 3 deletions(-)
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java
index e8aa921299..648306c7bc 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java
@@ -32,9 +32,11 @@ public final class BlockCategories {
public static final BlockCategory ANCIENT_CITY_REPLACEABLE = get("minecraft:ancient_city_replaceable");
public static final BlockCategory ANIMALS_SPAWNABLE_ON = get("minecraft:animals_spawnable_on");
public static final BlockCategory ANVIL = get("minecraft:anvil");
+ public static final BlockCategory ARMADILLO_SPAWNABLE_ON = get("minecraft:armadillo_spawnable_on");
public static final BlockCategory AXOLOTLS_SPAWNABLE_ON = get("minecraft:axolotls_spawnable_on");
public static final BlockCategory AZALEA_GROWS_ON = get("minecraft:azalea_grows_on");
public static final BlockCategory AZALEA_ROOT_REPLACEABLE = get("minecraft:azalea_root_replaceable");
+ public static final BlockCategory BADLANDS_TERRACOTTA = get("minecraft:badlands_terracotta");
public static final BlockCategory BAMBOO_BLOCKS = get("minecraft:bamboo_blocks");
public static final BlockCategory BAMBOO_PLANTABLE_ON = get("minecraft:bamboo_plantable_on");
public static final BlockCategory BANNERS = get("minecraft:banners");
@@ -76,6 +78,7 @@ public final class BlockCategories {
public static final BlockCategory DIAMOND_ORES = get("minecraft:diamond_ores");
public static final BlockCategory DIRT = get("minecraft:dirt");
@Deprecated public static final BlockCategory DIRT_LIKE = get("minecraft:dirt_like");
+ public static final BlockCategory DOES_NOT_BLOCK_HOPPERS = get("minecraft:does_not_block_hoppers");
public static final BlockCategory DOORS = get("minecraft:doors");
public static final BlockCategory DRAGON_IMMUNE = get("minecraft:dragon_immune");
public static final BlockCategory DRAGON_TRANSPARENT = get("minecraft:dragon_transparent");
@@ -101,6 +104,12 @@ public final class BlockCategories {
public static final BlockCategory HOGLIN_REPELLENTS = get("minecraft:hoglin_repellents");
public static final BlockCategory ICE = get("minecraft:ice");
public static final BlockCategory IMPERMEABLE = get("minecraft:impermeable");
+ public static final BlockCategory INCORRECT_FOR_DIAMOND_TOOL = get("minecraft:incorrect_for_diamond_tool");
+ public static final BlockCategory INCORRECT_FOR_GOLD_TOOL = get("minecraft:incorrect_for_gold_tool");
+ public static final BlockCategory INCORRECT_FOR_IRON_TOOL = get("minecraft:incorrect_for_iron_tool");
+ public static final BlockCategory INCORRECT_FOR_NETHERITE_TOOL = get("minecraft:incorrect_for_netherite_tool");
+ public static final BlockCategory INCORRECT_FOR_STONE_TOOL = get("minecraft:incorrect_for_stone_tool");
+ public static final BlockCategory INCORRECT_FOR_WOODEN_TOOL = get("minecraft:incorrect_for_wooden_tool");
public static final BlockCategory INFINIBURN_END = get("minecraft:infiniburn_end");
public static final BlockCategory INFINIBURN_NETHER = get("minecraft:infiniburn_nether");
public static final BlockCategory INFINIBURN_OVERWORLD = get("minecraft:infiniburn_overworld");
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java
index 8f788953fa..ec2298632e 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java
@@ -458,6 +458,7 @@ public final class BlockTypes {
@Nullable public static final BlockType GRINDSTONE = get("minecraft:grindstone");
@Nullable public static final BlockType HANGING_ROOTS = get("minecraft:hanging_roots");
@Nullable public static final BlockType HAY_BLOCK = get("minecraft:hay_block");
+ @Nullable public static final BlockType HEAVY_CORE = get("minecraft:heavy_core");
@Nullable public static final BlockType HEAVY_WEIGHTED_PRESSURE_PLATE = get("minecraft:heavy_weighted_pressure_plate");
@Nullable public static final BlockType HONEY_BLOCK = get("minecraft:honey_block");
@Nullable public static final BlockType HONEYCOMB_BLOCK = get("minecraft:honeycomb_block");
@@ -981,6 +982,7 @@ public final class BlockTypes {
@Nullable public static final BlockType TURTLE_EGG = get("minecraft:turtle_egg");
@Nullable public static final BlockType TWISTING_VINES = get("minecraft:twisting_vines");
@Nullable public static final BlockType TWISTING_VINES_PLANT = get("minecraft:twisting_vines_plant");
+ @Nullable public static final BlockType VAULT = get("minecraft:vault");
@Nullable public static final BlockType VERDANT_FROGLIGHT = get("minecraft:verdant_froglight");
@Nullable public static final BlockType VINE = get("minecraft:vine");
@Nullable public static final BlockType VOID_AIR = get("minecraft:void_air");
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java
index a66d665f8e..cc22b0e6db 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java
@@ -30,6 +30,7 @@
public final class EntityTypes {
@Nullable public static final EntityType ALLAY = get("minecraft:allay");
@Nullable public static final EntityType AREA_EFFECT_CLOUD = get("minecraft:area_effect_cloud");
+ @Nullable public static final EntityType ARMADILLO = get("minecraft:armadillo");
@Nullable public static final EntityType ARMOR_STAND = get("minecraft:armor_stand");
@Nullable public static final EntityType ARROW = get("minecraft:arrow");
@Nullable public static final EntityType AXOLOTL = get("minecraft:axolotl");
@@ -38,7 +39,9 @@ public final class EntityTypes {
@Nullable public static final EntityType BLAZE = get("minecraft:blaze");
@Nullable public static final EntityType BLOCK_DISPLAY = get("minecraft:block_display");
@Nullable public static final EntityType BOAT = get("minecraft:boat");
+ @Nullable public static final EntityType BOGGED = get("minecraft:bogged");
@Nullable public static final EntityType BREEZE = get("minecraft:breeze");
+ @Nullable public static final EntityType BREEZE_WIND_CHARGE = get("minecraft:breeze_wind_charge");
@Nullable public static final EntityType CAMEL = get("minecraft:camel");
@Nullable public static final EntityType CAT = get("minecraft:cat");
@Nullable public static final EntityType CAVE_SPIDER = get("minecraft:cave_spider");
@@ -98,6 +101,7 @@ public final class EntityTypes {
@Nullable public static final EntityType MOOSHROOM = get("minecraft:mooshroom");
@Nullable public static final EntityType MULE = get("minecraft:mule");
@Nullable public static final EntityType OCELOT = get("minecraft:ocelot");
+ @Nullable public static final EntityType OMINOUS_ITEM_SPAWNER = get("minecraft:ominous_item_spawner");
@Nullable public static final EntityType PAINTING = get("minecraft:painting");
@Nullable public static final EntityType PANDA = get("minecraft:panda");
@Nullable public static final EntityType PARROT = get("minecraft:parrot");
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java
index 91abe027f8..ac66c5c4f7 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java
@@ -28,28 +28,36 @@
public final class ItemCategories {
public static final ItemCategory ACACIA_LOGS = get("minecraft:acacia_logs");
public static final ItemCategory ANVIL = get("minecraft:anvil");
+ public static final ItemCategory ARMADILLO_FOOD = get("minecraft:armadillo_food");
public static final ItemCategory ARROWS = get("minecraft:arrows");
public static final ItemCategory AXES = get("minecraft:axes");
- public static final ItemCategory AXOLOTL_TEMPT_ITEMS = get("minecraft:axolotl_tempt_items");
+ public static final ItemCategory AXOLOTL_FOOD = get("minecraft:axolotl_food");
+ @Deprecated public static final ItemCategory AXOLOTL_TEMPT_ITEMS = get("minecraft:axolotl_tempt_items");
public static final ItemCategory BAMBOO_BLOCKS = get("minecraft:bamboo_blocks");
public static final ItemCategory BANNERS = get("minecraft:banners");
public static final ItemCategory BEACON_PAYMENT_ITEMS = get("minecraft:beacon_payment_items");
public static final ItemCategory BEDS = get("minecraft:beds");
+ public static final ItemCategory BEE_FOOD = get("minecraft:bee_food");
public static final ItemCategory BIRCH_LOGS = get("minecraft:birch_logs");
public static final ItemCategory BOATS = get("minecraft:boats");
public static final ItemCategory BOOKSHELF_BOOKS = get("minecraft:bookshelf_books");
public static final ItemCategory BREAKS_DECORATED_POTS = get("minecraft:breaks_decorated_pots");
public static final ItemCategory BUTTONS = get("minecraft:buttons");
+ public static final ItemCategory CAMEL_FOOD = get("minecraft:camel_food");
public static final ItemCategory CANDLES = get("minecraft:candles");
@Deprecated public static final ItemCategory CARPETS = get("minecraft:carpets");
+ public static final ItemCategory CAT_FOOD = get("minecraft:cat_food");
public static final ItemCategory CHERRY_LOGS = get("minecraft:cherry_logs");
+ public static final ItemCategory CHEST_ARMOR = get("minecraft:chest_armor");
public static final ItemCategory CHEST_BOATS = get("minecraft:chest_boats");
+ public static final ItemCategory CHICKEN_FOOD = get("minecraft:chicken_food");
public static final ItemCategory CLUSTER_MAX_HARVESTABLES = get("minecraft:cluster_max_harvestables");
public static final ItemCategory COAL_ORES = get("minecraft:coal_ores");
public static final ItemCategory COALS = get("minecraft:coals");
public static final ItemCategory COMPASSES = get("minecraft:compasses");
public static final ItemCategory COMPLETES_FIND_TREE_TUTORIAL = get("minecraft:completes_find_tree_tutorial");
public static final ItemCategory COPPER_ORES = get("minecraft:copper_ores");
+ public static final ItemCategory COW_FOOD = get("minecraft:cow_food");
public static final ItemCategory CREEPER_DROP_MUSIC_DISCS = get("minecraft:creeper_drop_music_discs");
public static final ItemCategory CREEPER_IGNITERS = get("minecraft:creeper_igniters");
public static final ItemCategory CRIMSON_STEMS = get("minecraft:crimson_stems");
@@ -60,43 +68,81 @@ public final class ItemCategories {
public static final ItemCategory DIAMOND_ORES = get("minecraft:diamond_ores");
public static final ItemCategory DIRT = get("minecraft:dirt");
public static final ItemCategory DOORS = get("minecraft:doors");
+ public static final ItemCategory DYEABLE = get("minecraft:dyeable");
public static final ItemCategory EMERALD_ORES = get("minecraft:emerald_ores");
+ public static final ItemCategory ENCHANTABLE_ARMOR = get("minecraft:enchantable/armor");
+ public static final ItemCategory ENCHANTABLE_BOW = get("minecraft:enchantable/bow");
+ public static final ItemCategory ENCHANTABLE_CHEST_ARMOR = get("minecraft:enchantable/chest_armor");
+ public static final ItemCategory ENCHANTABLE_CROSSBOW = get("minecraft:enchantable/crossbow");
+ public static final ItemCategory ENCHANTABLE_DURABILITY = get("minecraft:enchantable/durability");
+ public static final ItemCategory ENCHANTABLE_EQUIPPABLE = get("minecraft:enchantable/equippable");
+ public static final ItemCategory ENCHANTABLE_FIRE_ASPECT = get("minecraft:enchantable/fire_aspect");
+ public static final ItemCategory ENCHANTABLE_FISHING = get("minecraft:enchantable/fishing");
+ public static final ItemCategory ENCHANTABLE_FOOT_ARMOR = get("minecraft:enchantable/foot_armor");
+ public static final ItemCategory ENCHANTABLE_HEAD_ARMOR = get("minecraft:enchantable/head_armor");
+ public static final ItemCategory ENCHANTABLE_LEG_ARMOR = get("minecraft:enchantable/leg_armor");
+ public static final ItemCategory ENCHANTABLE_MINING = get("minecraft:enchantable/mining");
+ public static final ItemCategory ENCHANTABLE_MINING_LOOT = get("minecraft:enchantable/mining_loot");
+ public static final ItemCategory ENCHANTABLE_SHARP_WEAPON = get("minecraft:enchantable/sharp_weapon");
+ public static final ItemCategory ENCHANTABLE_SWORD = get("minecraft:enchantable/sword");
+ public static final ItemCategory ENCHANTABLE_TRIDENT = get("minecraft:enchantable/trident");
+ public static final ItemCategory ENCHANTABLE_VANISHING = get("minecraft:enchantable/vanishing");
+ public static final ItemCategory ENCHANTABLE_WEAPON = get("minecraft:enchantable/weapon");
public static final ItemCategory FENCE_GATES = get("minecraft:fence_gates");
public static final ItemCategory FENCES = get("minecraft:fences");
public static final ItemCategory FISHES = get("minecraft:fishes");
public static final ItemCategory FLOWERS = get("minecraft:flowers");
+ public static final ItemCategory FOOT_ARMOR = get("minecraft:foot_armor");
public static final ItemCategory FOX_FOOD = get("minecraft:fox_food");
public static final ItemCategory FREEZE_IMMUNE_WEARABLES = get("minecraft:freeze_immune_wearables");
+ public static final ItemCategory FROG_FOOD = get("minecraft:frog_food");
@Deprecated public static final ItemCategory FURNACE_MATERIALS = get("minecraft:furnace_materials");
+ public static final ItemCategory GOAT_FOOD = get("minecraft:goat_food");
public static final ItemCategory GOLD_ORES = get("minecraft:gold_ores");
public static final ItemCategory HANGING_SIGNS = get("minecraft:hanging_signs");
+ public static final ItemCategory HEAD_ARMOR = get("minecraft:head_armor");
public static final ItemCategory HOES = get("minecraft:hoes");
+ public static final ItemCategory HOGLIN_FOOD = get("minecraft:hoglin_food");
+ public static final ItemCategory HORSE_FOOD = get("minecraft:horse_food");
+ public static final ItemCategory HORSE_TEMPT_ITEMS = get("minecraft:horse_tempt_items");
public static final ItemCategory IGNORED_BY_PIGLIN_BABIES = get("minecraft:ignored_by_piglin_babies");
public static final ItemCategory IRON_ORES = get("minecraft:iron_ores");
public static final ItemCategory JUNGLE_LOGS = get("minecraft:jungle_logs");
public static final ItemCategory LAPIS_ORES = get("minecraft:lapis_ores");
public static final ItemCategory LEAVES = get("minecraft:leaves");
public static final ItemCategory LECTERN_BOOKS = get("minecraft:lectern_books");
+ public static final ItemCategory LEG_ARMOR = get("minecraft:leg_armor");
+ public static final ItemCategory LLAMA_FOOD = get("minecraft:llama_food");
+ public static final ItemCategory LLAMA_TEMPT_ITEMS = get("minecraft:llama_tempt_items");
public static final ItemCategory LOGS = get("minecraft:logs");
public static final ItemCategory LOGS_THAT_BURN = get("minecraft:logs_that_burn");
public static final ItemCategory MANGROVE_LOGS = get("minecraft:mangrove_logs");
+ public static final ItemCategory MEAT = get("minecraft:meat");
public static final ItemCategory MUSIC_DISCS = get("minecraft:music_discs");
public static final ItemCategory NON_FLAMMABLE_WOOD = get("minecraft:non_flammable_wood");
public static final ItemCategory NOTEBLOCK_TOP_INSTRUMENTS = get("minecraft:noteblock_top_instruments");
public static final ItemCategory OAK_LOGS = get("minecraft:oak_logs");
@Deprecated public static final ItemCategory OCCLUDES_VIBRATION_SIGNALS = get("minecraft:occludes_vibration_signals");
+ public static final ItemCategory OCELOT_FOOD = get("minecraft:ocelot_food");
@Deprecated public static final ItemCategory OVERWORLD_NATURAL_LOGS = get("minecraft:overworld_natural_logs");
+ public static final ItemCategory PANDA_FOOD = get("minecraft:panda_food");
+ public static final ItemCategory PARROT_FOOD = get("minecraft:parrot_food");
+ public static final ItemCategory PARROT_POISONOUS_FOOD = get("minecraft:parrot_poisonous_food");
public static final ItemCategory PICKAXES = get("minecraft:pickaxes");
+ public static final ItemCategory PIG_FOOD = get("minecraft:pig_food");
public static final ItemCategory PIGLIN_FOOD = get("minecraft:piglin_food");
public static final ItemCategory PIGLIN_LOVED = get("minecraft:piglin_loved");
public static final ItemCategory PIGLIN_REPELLENTS = get("minecraft:piglin_repellents");
public static final ItemCategory PLANKS = get("minecraft:planks");
+ public static final ItemCategory RABBIT_FOOD = get("minecraft:rabbit_food");
public static final ItemCategory RAILS = get("minecraft:rails");
public static final ItemCategory REDSTONE_ORES = get("minecraft:redstone_ores");
public static final ItemCategory SAND = get("minecraft:sand");
public static final ItemCategory SAPLINGS = get("minecraft:saplings");
+ public static final ItemCategory SHEEP_FOOD = get("minecraft:sheep_food");
public static final ItemCategory SHOVELS = get("minecraft:shovels");
public static final ItemCategory SIGNS = get("minecraft:signs");
+ public static final ItemCategory SKULLS = get("minecraft:skulls");
public static final ItemCategory SLABS = get("minecraft:slabs");
public static final ItemCategory SMALL_FLOWERS = get("minecraft:small_flowers");
public static final ItemCategory SMELTS_TO_GLASS = get("minecraft:smelts_to_glass");
@@ -108,18 +154,22 @@ public final class ItemCategories {
public static final ItemCategory STONE_BUTTONS = get("minecraft:stone_buttons");
public static final ItemCategory STONE_CRAFTING_MATERIALS = get("minecraft:stone_crafting_materials");
public static final ItemCategory STONE_TOOL_MATERIALS = get("minecraft:stone_tool_materials");
+ public static final ItemCategory STRIDER_FOOD = get("minecraft:strider_food");
+ public static final ItemCategory STRIDER_TEMPT_ITEMS = get("minecraft:strider_tempt_items");
public static final ItemCategory SWORDS = get("minecraft:swords");
public static final ItemCategory TALL_FLOWERS = get("minecraft:tall_flowers");
public static final ItemCategory TERRACOTTA = get("minecraft:terracotta");
- public static final ItemCategory TOOLS = get("minecraft:tools");
+ @Deprecated public static final ItemCategory TOOLS = get("minecraft:tools");
public static final ItemCategory TRAPDOORS = get("minecraft:trapdoors");
public static final ItemCategory TRIM_MATERIALS = get("minecraft:trim_materials");
public static final ItemCategory TRIM_TEMPLATES = get("minecraft:trim_templates");
public static final ItemCategory TRIMMABLE_ARMOR = get("minecraft:trimmable_armor");
+ public static final ItemCategory TURTLE_FOOD = get("minecraft:turtle_food");
public static final ItemCategory VILLAGER_PLANTABLE_SEEDS = get("minecraft:villager_plantable_seeds");
public static final ItemCategory WALLS = get("minecraft:walls");
public static final ItemCategory WARPED_STEMS = get("minecraft:warped_stems");
public static final ItemCategory WART_BLOCKS = get("minecraft:wart_blocks");
+ public static final ItemCategory WOLF_FOOD = get("minecraft:wolf_food");
public static final ItemCategory WOODEN_BUTTONS = get("minecraft:wooden_buttons");
public static final ItemCategory WOODEN_DOORS = get("minecraft:wooden_doors");
public static final ItemCategory WOODEN_FENCES = get("minecraft:wooden_fences");
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java
index ba0d0613fa..f9ef041c40 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java
@@ -61,6 +61,8 @@ public final class ItemTypes {
@Nullable public static final ItemType ANVIL = get("minecraft:anvil");
@Nullable public static final ItemType APPLE = get("minecraft:apple");
@Nullable public static final ItemType ARCHER_POTTERY_SHERD = get("minecraft:archer_pottery_sherd");
+ @Nullable public static final ItemType ARMADILLO_SCUTE = get("minecraft:armadillo_scute");
+ @Nullable public static final ItemType ARMADILLO_SPAWN_EGG = get("minecraft:armadillo_spawn_egg");
@Nullable public static final ItemType ARMOR_STAND = get("minecraft:armor_stand");
@Nullable public static final ItemType ARMS_UP_POTTERY_SHERD = get("minecraft:arms_up_pottery_sherd");
@Nullable public static final ItemType ARROW = get("minecraft:arrow");
@@ -157,6 +159,8 @@ public final class ItemTypes {
@Nullable public static final ItemType BLUE_STAINED_GLASS_PANE = get("minecraft:blue_stained_glass_pane");
@Nullable public static final ItemType BLUE_TERRACOTTA = get("minecraft:blue_terracotta");
@Nullable public static final ItemType BLUE_WOOL = get("minecraft:blue_wool");
+ @Nullable public static final ItemType BOGGED_SPAWN_EGG = get("minecraft:bogged_spawn_egg");
+ @Nullable public static final ItemType BOLT_ARMOR_TRIM_SMITHING_TEMPLATE = get("minecraft:bolt_armor_trim_smithing_template");
@Nullable public static final ItemType BONE = get("minecraft:bone");
@Nullable public static final ItemType BONE_BLOCK = get("minecraft:bone_block");
@Nullable public static final ItemType BONE_MEAL = get("minecraft:bone_meal");
@@ -168,6 +172,7 @@ public final class ItemTypes {
@Nullable public static final ItemType BRAIN_CORAL_BLOCK = get("minecraft:brain_coral_block");
@Nullable public static final ItemType BRAIN_CORAL_FAN = get("minecraft:brain_coral_fan");
@Nullable public static final ItemType BREAD = get("minecraft:bread");
+ @Nullable public static final ItemType BREEZE_ROD = get("minecraft:breeze_rod");
@Nullable public static final ItemType BREEZE_SPAWN_EGG = get("minecraft:breeze_spawn_egg");
@Nullable public static final ItemType BREWER_POTTERY_SHERD = get("minecraft:brewer_pottery_sherd");
@Nullable public static final ItemType BREWING_STAND = get("minecraft:brewing_stand");
@@ -494,6 +499,9 @@ public final class ItemTypes {
@Nullable public static final ItemType FLETCHING_TABLE = get("minecraft:fletching_table");
@Nullable public static final ItemType FLINT = get("minecraft:flint");
@Nullable public static final ItemType FLINT_AND_STEEL = get("minecraft:flint_and_steel");
+ @Nullable public static final ItemType FLOW_ARMOR_TRIM_SMITHING_TEMPLATE = get("minecraft:flow_armor_trim_smithing_template");
+ @Nullable public static final ItemType FLOW_BANNER_PATTERN = get("minecraft:flow_banner_pattern");
+ @Nullable public static final ItemType FLOW_POTTERY_SHERD = get("minecraft:flow_pottery_sherd");
@Nullable public static final ItemType FLOWER_BANNER_PATTERN = get("minecraft:flower_banner_pattern");
@Nullable public static final ItemType FLOWER_POT = get("minecraft:flower_pot");
@Nullable public static final ItemType FLOWERING_AZALEA = get("minecraft:flowering_azalea");
@@ -574,11 +582,14 @@ public final class ItemTypes {
@Nullable public static final ItemType GRINDSTONE = get("minecraft:grindstone");
@Nullable public static final ItemType GUARDIAN_SPAWN_EGG = get("minecraft:guardian_spawn_egg");
@Nullable public static final ItemType GUNPOWDER = get("minecraft:gunpowder");
+ @Nullable public static final ItemType GUSTER_BANNER_PATTERN = get("minecraft:guster_banner_pattern");
+ @Nullable public static final ItemType GUSTER_POTTERY_SHERD = get("minecraft:guster_pottery_sherd");
@Nullable public static final ItemType HANGING_ROOTS = get("minecraft:hanging_roots");
@Nullable public static final ItemType HAY_BLOCK = get("minecraft:hay_block");
@Nullable public static final ItemType HEART_OF_THE_SEA = get("minecraft:heart_of_the_sea");
@Nullable public static final ItemType HEART_POTTERY_SHERD = get("minecraft:heart_pottery_sherd");
@Nullable public static final ItemType HEARTBREAK_POTTERY_SHERD = get("minecraft:heartbreak_pottery_sherd");
+ @Nullable public static final ItemType HEAVY_CORE = get("minecraft:heavy_core");
@Nullable public static final ItemType HEAVY_WEIGHTED_PRESSURE_PLATE = get("minecraft:heavy_weighted_pressure_plate");
@Nullable public static final ItemType HOGLIN_SPAWN_EGG = get("minecraft:hoglin_spawn_egg");
@Nullable public static final ItemType HONEY_BLOCK = get("minecraft:honey_block");
@@ -710,6 +721,7 @@ public final class ItemTypes {
@Nullable public static final ItemType LLAMA_SPAWN_EGG = get("minecraft:llama_spawn_egg");
@Nullable public static final ItemType LODESTONE = get("minecraft:lodestone");
@Nullable public static final ItemType LOOM = get("minecraft:loom");
+ @Nullable public static final ItemType MACE = get("minecraft:mace");
@Nullable public static final ItemType MAGENTA_BANNER = get("minecraft:magenta_banner");
@Nullable public static final ItemType MAGENTA_BED = get("minecraft:magenta_bed");
@Nullable public static final ItemType MAGENTA_CANDLE = get("minecraft:magenta_candle");
@@ -842,6 +854,8 @@ public final class ItemTypes {
@Nullable public static final ItemType OBSIDIAN = get("minecraft:obsidian");
@Nullable public static final ItemType OCELOT_SPAWN_EGG = get("minecraft:ocelot_spawn_egg");
@Nullable public static final ItemType OCHRE_FROGLIGHT = get("minecraft:ochre_froglight");
+ @Nullable public static final ItemType OMINOUS_BOTTLE = get("minecraft:ominous_bottle");
+ @Nullable public static final ItemType OMINOUS_TRIAL_KEY = get("minecraft:ominous_trial_key");
@Nullable public static final ItemType ORANGE_BANNER = get("minecraft:orange_banner");
@Nullable public static final ItemType ORANGE_BED = get("minecraft:orange_bed");
@Nullable public static final ItemType ORANGE_CANDLE = get("minecraft:orange_candle");
@@ -1045,12 +1059,13 @@ public final class ItemTypes {
@Nullable public static final ItemType SANDSTONE_STAIRS = get("minecraft:sandstone_stairs");
@Nullable public static final ItemType SANDSTONE_WALL = get("minecraft:sandstone_wall");
@Nullable public static final ItemType SCAFFOLDING = get("minecraft:scaffolding");
+ @Nullable public static final ItemType SCRAPE_POTTERY_SHERD = get("minecraft:scrape_pottery_sherd");
@Nullable public static final ItemType SCULK = get("minecraft:sculk");
@Nullable public static final ItemType SCULK_CATALYST = get("minecraft:sculk_catalyst");
@Nullable public static final ItemType SCULK_SENSOR = get("minecraft:sculk_sensor");
@Nullable public static final ItemType SCULK_SHRIEKER = get("minecraft:sculk_shrieker");
@Nullable public static final ItemType SCULK_VEIN = get("minecraft:sculk_vein");
- @Nullable public static final ItemType SCUTE = get("minecraft:scute");
+ @Deprecated @Nullable public static final ItemType SCUTE = get("minecraft:scute");
@Nullable public static final ItemType SEA_LANTERN = get("minecraft:sea_lantern");
@Nullable public static final ItemType SEA_PICKLE = get("minecraft:sea_pickle");
@Nullable public static final ItemType SEAGRASS = get("minecraft:seagrass");
@@ -1219,8 +1234,10 @@ public final class ItemTypes {
@Nullable public static final ItemType TUFF_WALL = get("minecraft:tuff_wall");
@Nullable public static final ItemType TURTLE_EGG = get("minecraft:turtle_egg");
@Nullable public static final ItemType TURTLE_HELMET = get("minecraft:turtle_helmet");
+ @Nullable public static final ItemType TURTLE_SCUTE = get("minecraft:turtle_scute");
@Nullable public static final ItemType TURTLE_SPAWN_EGG = get("minecraft:turtle_spawn_egg");
@Nullable public static final ItemType TWISTING_VINES = get("minecraft:twisting_vines");
+ @Nullable public static final ItemType VAULT = get("minecraft:vault");
@Nullable public static final ItemType VERDANT_FROGLIGHT = get("minecraft:verdant_froglight");
@Nullable public static final ItemType VEX_ARMOR_TRIM_SMITHING_TEMPLATE = get("minecraft:vex_armor_trim_smithing_template");
@Nullable public static final ItemType VEX_SPAWN_EGG = get("minecraft:vex_spawn_egg");
@@ -1314,11 +1331,13 @@ public final class ItemTypes {
@Nullable public static final ItemType WHITE_TULIP = get("minecraft:white_tulip");
@Nullable public static final ItemType WHITE_WOOL = get("minecraft:white_wool");
@Nullable public static final ItemType WILD_ARMOR_TRIM_SMITHING_TEMPLATE = get("minecraft:wild_armor_trim_smithing_template");
+ @Nullable public static final ItemType WIND_CHARGE = get("minecraft:wind_charge");
@Nullable public static final ItemType WITCH_SPAWN_EGG = get("minecraft:witch_spawn_egg");
@Nullable public static final ItemType WITHER_ROSE = get("minecraft:wither_rose");
@Nullable public static final ItemType WITHER_SKELETON_SKULL = get("minecraft:wither_skeleton_skull");
@Nullable public static final ItemType WITHER_SKELETON_SPAWN_EGG = get("minecraft:wither_skeleton_spawn_egg");
@Nullable public static final ItemType WITHER_SPAWN_EGG = get("minecraft:wither_spawn_egg");
+ @Nullable public static final ItemType WOLF_ARMOR = get("minecraft:wolf_armor");
@Nullable public static final ItemType WOLF_SPAWN_EGG = get("minecraft:wolf_spawn_egg");
@Nullable public static final ItemType WOODEN_AXE = get("minecraft:wooden_axe");
@Nullable public static final ItemType WOODEN_HOE = get("minecraft:wooden_hoe");
From 4606e700b466a39b1ebd96fa8aeb4a62ae0f2f30 Mon Sep 17 00:00:00 2001
From: Madeline Miller
Date: Sat, 27 Apr 2024 14:10:42 +1000
Subject: [PATCH 12/21] [Bukkit] Update for 1.20.5
---
buildSrc/build.gradle.kts | 2 +-
settings.gradle.kts | 2 +-
.../adapters/adapter-1.20.5/build.gradle.kts | 8 +
.../impl/v1_20_R4/PaperweightAdapter.java | 1206 +++++++
.../v1_20_R4/PaperweightDataConverters.java | 2803 +++++++++++++++++
.../impl/v1_20_R4/PaperweightFakePlayer.java | 98 +
.../PaperweightServerLevelDelegateProxy.java | 153 +
.../PaperweightWorldNativeAccess.java | 186 ++
8 files changed, 4456 insertions(+), 2 deletions(-)
create mode 100644 worldedit-bukkit/adapters/adapter-1.20.5/build.gradle.kts
create mode 100644 worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightAdapter.java
create mode 100644 worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightDataConverters.java
create mode 100644 worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightFakePlayer.java
create mode 100644 worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightServerLevelDelegateProxy.java
create mode 100644 worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightWorldNativeAccess.java
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
index e21b712529..3b4300289d 100644
--- a/buildSrc/build.gradle.kts
+++ b/buildSrc/build.gradle.kts
@@ -58,7 +58,7 @@ dependencies {
implementation("net.fabricmc:fabric-loom:$loomVersion")
implementation("net.fabricmc:sponge-mixin:$mixinVersion")
implementation("org.enginehub.gradle:gradle-codecov-plugin:0.2.0")
- implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.5.13")
+ implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.6.0")
constraints {
val asmVersion = "[9.7,)"
implementation("org.ow2.asm:asm:$asmVersion") {
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 883e10a287..b5dc755413 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -16,7 +16,7 @@ rootProject.name = "worldedit"
include("worldedit-libs")
-listOf("1.19.4", "1.20", "1.20.2", "1.20.4").forEach {
+listOf("1.19.4", "1.20", "1.20.2", "1.20.4", "1.20.5").forEach {
include("worldedit-bukkit:adapters:adapter-$it")
}
diff --git a/worldedit-bukkit/adapters/adapter-1.20.5/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1.20.5/build.gradle.kts
new file mode 100644
index 0000000000..4cf500733a
--- /dev/null
+++ b/worldedit-bukkit/adapters/adapter-1.20.5/build.gradle.kts
@@ -0,0 +1,8 @@
+import io.papermc.paperweight.userdev.PaperweightUserDependenciesExtension
+
+applyPaperweightAdapterConfiguration()
+
+dependencies {
+ // https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
+ the().paperDevBundle("1.20.5-R0.1-20240426.233703-2")
+}
diff --git a/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightAdapter.java
new file mode 100644
index 0000000000..c20b5a9749
--- /dev/null
+++ b/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightAdapter.java
@@ -0,0 +1,1206 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.bukkit.adapter.impl.v1_20_R4;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.Futures;
+import com.mojang.serialization.Codec;
+import com.mojang.serialization.Lifecycle;
+import com.sk89q.worldedit.EditSession;
+import com.sk89q.worldedit.WorldEditException;
+import com.sk89q.worldedit.blocks.BaseItem;
+import com.sk89q.worldedit.blocks.BaseItemStack;
+import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
+import com.sk89q.worldedit.bukkit.adapter.Refraction;
+import com.sk89q.worldedit.entity.BaseEntity;
+import com.sk89q.worldedit.extension.platform.Watchdog;
+import com.sk89q.worldedit.extent.Extent;
+import com.sk89q.worldedit.internal.Constants;
+import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
+import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.regions.Region;
+import com.sk89q.worldedit.registry.state.BooleanProperty;
+import com.sk89q.worldedit.registry.state.DirectionalProperty;
+import com.sk89q.worldedit.registry.state.EnumProperty;
+import com.sk89q.worldedit.registry.state.IntegerProperty;
+import com.sk89q.worldedit.registry.state.Property;
+import com.sk89q.worldedit.util.Direction;
+import com.sk89q.worldedit.util.SideEffect;
+import com.sk89q.worldedit.util.concurrency.LazyReference;
+import com.sk89q.worldedit.util.formatting.text.Component;
+import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
+import com.sk89q.worldedit.util.io.file.SafeFiles;
+import com.sk89q.worldedit.world.DataFixer;
+import com.sk89q.worldedit.world.RegenOptions;
+import com.sk89q.worldedit.world.biome.BiomeCategory;
+import com.sk89q.worldedit.world.biome.BiomeType;
+import com.sk89q.worldedit.world.biome.BiomeTypes;
+import com.sk89q.worldedit.world.block.BaseBlock;
+import com.sk89q.worldedit.world.block.BlockState;
+import com.sk89q.worldedit.world.block.BlockStateHolder;
+import com.sk89q.worldedit.world.block.BlockType;
+import com.sk89q.worldedit.world.block.BlockTypes;
+import com.sk89q.worldedit.world.entity.EntityTypes;
+import com.sk89q.worldedit.world.generation.ConfiguredFeatureType;
+import com.sk89q.worldedit.world.generation.StructureType;
+import com.sk89q.worldedit.world.item.ItemType;
+import net.minecraft.Util;
+import net.minecraft.core.BlockPos;
+import net.minecraft.core.Holder;
+import net.minecraft.core.HolderSet;
+import net.minecraft.core.Registry;
+import net.minecraft.core.SectionPos;
+import net.minecraft.core.component.DataComponentPatch;
+import net.minecraft.core.registries.Registries;
+import net.minecraft.nbt.ByteArrayTag;
+import net.minecraft.nbt.ByteTag;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.DoubleTag;
+import net.minecraft.nbt.EndTag;
+import net.minecraft.nbt.FloatTag;
+import net.minecraft.nbt.IntArrayTag;
+import net.minecraft.nbt.IntTag;
+import net.minecraft.nbt.ListTag;
+import net.minecraft.nbt.LongArrayTag;
+import net.minecraft.nbt.LongTag;
+import net.minecraft.nbt.NbtOps;
+import net.minecraft.nbt.ShortTag;
+import net.minecraft.nbt.StringTag;
+import net.minecraft.nbt.Tag;
+import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
+import net.minecraft.network.protocol.game.ClientboundEntityEventPacket;
+import net.minecraft.resources.ResourceKey;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.dedicated.DedicatedServer;
+import net.minecraft.server.level.ChunkResult;
+import net.minecraft.server.level.ServerChunkCache;
+import net.minecraft.server.level.ServerLevel;
+import net.minecraft.server.level.progress.ChunkProgressListener;
+import net.minecraft.util.RandomSource;
+import net.minecraft.util.StringRepresentable;
+import net.minecraft.util.thread.BlockableEventLoop;
+import net.minecraft.world.Clearable;
+import net.minecraft.world.InteractionHand;
+import net.minecraft.world.InteractionResult;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.EntityType;
+import net.minecraft.world.item.Item;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.context.UseOnContext;
+import net.minecraft.world.level.ChunkPos;
+import net.minecraft.world.level.LevelSettings;
+import net.minecraft.world.level.WorldGenLevel;
+import net.minecraft.world.level.biome.Biome;
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.Blocks;
+import net.minecraft.world.level.block.entity.BlockEntity;
+import net.minecraft.world.level.block.entity.StructureBlockEntity;
+import net.minecraft.world.level.block.state.StateDefinition;
+import net.minecraft.world.level.block.state.properties.DirectionProperty;
+import net.minecraft.world.level.chunk.ChunkAccess;
+import net.minecraft.world.level.chunk.LevelChunk;
+import net.minecraft.world.level.chunk.status.ChunkStatus;
+import net.minecraft.world.level.dimension.LevelStem;
+import net.minecraft.world.level.levelgen.WorldOptions;
+import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
+import net.minecraft.world.level.levelgen.structure.BoundingBox;
+import net.minecraft.world.level.levelgen.structure.Structure;
+import net.minecraft.world.level.levelgen.structure.StructureStart;
+import net.minecraft.world.level.storage.LevelStorageSource;
+import net.minecraft.world.level.storage.PrimaryLevelData;
+import net.minecraft.world.phys.BlockHitResult;
+import net.minecraft.world.phys.Vec3;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.World.Environment;
+import org.bukkit.block.data.BlockData;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.block.data.CraftBlockData;
+import org.bukkit.craftbukkit.entity.CraftEntity;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.entity.Player;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+import org.bukkit.generator.ChunkGenerator;
+import org.enginehub.linbus.common.LinTagId;
+import org.enginehub.linbus.tree.LinByteArrayTag;
+import org.enginehub.linbus.tree.LinByteTag;
+import org.enginehub.linbus.tree.LinCompoundTag;
+import org.enginehub.linbus.tree.LinDoubleTag;
+import org.enginehub.linbus.tree.LinEndTag;
+import org.enginehub.linbus.tree.LinFloatTag;
+import org.enginehub.linbus.tree.LinIntArrayTag;
+import org.enginehub.linbus.tree.LinIntTag;
+import org.enginehub.linbus.tree.LinListTag;
+import org.enginehub.linbus.tree.LinLongArrayTag;
+import org.enginehub.linbus.tree.LinLongTag;
+import org.enginehub.linbus.tree.LinShortTag;
+import org.enginehub.linbus.tree.LinStringTag;
+import org.enginehub.linbus.tree.LinTag;
+import org.enginehub.linbus.tree.LinTagType;
+import org.spigotmc.SpigotConfig;
+import org.spigotmc.WatchdogThread;
+
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Objects;
+import java.util.OptionalInt;
+import java.util.OptionalLong;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import javax.annotation.Nullable;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
+public final class PaperweightAdapter implements BukkitImplAdapter {
+
+ private final Logger logger = Logger.getLogger(getClass().getCanonicalName());
+
+ private final Field serverWorldsField;
+ private final Method getChunkFutureMethod;
+ private final Field chunkProviderExecutorField;
+ private final Watchdog watchdog;
+
+ private static final RandomSource random = RandomSource.create();
+
+ // ------------------------------------------------------------------------
+ // Code that may break between versions of Minecraft
+ // ------------------------------------------------------------------------
+
+ public PaperweightAdapter() throws NoSuchFieldException, NoSuchMethodException {
+ // A simple test
+ CraftServer.class.cast(Bukkit.getServer());
+
+ int dataVersion = CraftMagicNumbers.INSTANCE.getDataVersion();
+ if (dataVersion != 3837) {
+ throw new UnsupportedClassVersionError("Not 1.20.5!");
+ }
+
+ serverWorldsField = CraftServer.class.getDeclaredField("worlds");
+ serverWorldsField.setAccessible(true);
+
+ getChunkFutureMethod = ServerChunkCache.class.getDeclaredMethod(
+ Refraction.pickName("getChunkFutureMainThread", "c"),
+ int.class, int.class, ChunkStatus.class, boolean.class
+ );
+ getChunkFutureMethod.setAccessible(true);
+
+ chunkProviderExecutorField = ServerChunkCache.class.getDeclaredField(
+ Refraction.pickName("mainThreadProcessor", "g")
+ );
+ chunkProviderExecutorField.setAccessible(true);
+
+ new PaperweightDataConverters(CraftMagicNumbers.INSTANCE.getDataVersion(), this).buildUnoptimized();
+
+ Watchdog watchdog;
+ try {
+ Class.forName("org.spigotmc.WatchdogThread");
+ watchdog = new SpigotWatchdog();
+ } catch (ClassNotFoundException | NoSuchFieldException e) {
+ try {
+ watchdog = new MojangWatchdog(((CraftServer) Bukkit.getServer()).getServer());
+ } catch (NoSuchFieldException ex) {
+ watchdog = null;
+ }
+ }
+ this.watchdog = watchdog;
+
+ try {
+ Class.forName("org.spigotmc.SpigotConfig");
+ SpigotConfig.config.set("world-settings.worldeditregentempworld.verbose", false);
+ } catch (ClassNotFoundException ignored) {
+ }
+ }
+
+ @Override
+ public DataFixer getDataFixer() {
+ return PaperweightDataConverters.INSTANCE;
+ }
+
+ /**
+ * Read the given NBT data into the given tile entity.
+ *
+ * @param tileEntity the tile entity
+ * @param tag the tag
+ */
+ static void readTagIntoTileEntity(net.minecraft.nbt.CompoundTag tag, BlockEntity tileEntity) {
+ tileEntity.loadWithComponents(tag, MinecraftServer.getServer().registryAccess());
+ tileEntity.setChanged();
+ }
+
+ /**
+ * Get the ID string of the given entity.
+ *
+ * @param entity the entity
+ * @return the entity ID
+ */
+ private static String getEntityId(Entity entity) {
+ return EntityType.getKey(entity.getType()).toString();
+ }
+
+ /**
+ * Create an entity using the given entity ID.
+ *
+ * @param id the entity ID
+ * @param world the world
+ * @return an entity or null
+ */
+ @Nullable
+ private static Entity createEntityFromId(String id, net.minecraft.world.level.Level world) {
+ return EntityType.byString(id).map(t -> t.create(world)).orElse(null);
+ }
+
+ /**
+ * Write the given NBT data into the given entity.
+ *
+ * @param entity the entity
+ * @param tag the tag
+ */
+ private static void readTagIntoEntity(net.minecraft.nbt.CompoundTag tag, Entity entity) {
+ entity.load(tag);
+ }
+
+ /**
+ * Write the entity's NBT data to the given tag.
+ *
+ * @param entity the entity
+ * @param tag the tag
+ */
+ private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag tag) {
+ entity.save(tag);
+ }
+
+ private static Block getBlockFromType(BlockType blockType) {
+ return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
+ }
+
+ private static Item getItemFromType(ItemType itemType) {
+ return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
+ }
+
+ @Override
+ public OptionalInt getInternalBlockStateId(BlockData data) {
+ net.minecraft.world.level.block.state.BlockState state = ((CraftBlockData) data).getState();
+ int combinedId = Block.getId(state);
+ return combinedId == 0 && state.getBlock() != Blocks.AIR ? OptionalInt.empty() : OptionalInt.of(combinedId);
+ }
+
+ @Override
+ public OptionalInt getInternalBlockStateId(BlockState state) {
+ Block mcBlock = getBlockFromType(state.getBlockType());
+ net.minecraft.world.level.block.state.BlockState newState = mcBlock.defaultBlockState();
+ Map, Object> states = state.getStates();
+ newState = applyProperties(mcBlock.getStateDefinition(), newState, states);
+ final int combinedId = Block.getId(newState);
+ return combinedId == 0 && state.getBlockType() != BlockTypes.AIR ? OptionalInt.empty() : OptionalInt.of(combinedId);
+ }
+
+ public BlockState adapt(net.minecraft.world.level.block.state.BlockState blockState) {
+ int internalId = Block.getId(blockState);
+ BlockState state = BlockStateIdAccess.getBlockStateById(internalId);
+ if (state == null) {
+ state = BukkitAdapter.adapt(CraftBlockData.createData(blockState));
+ }
+
+ return state;
+ }
+
+ public BiomeType adapt(Biome biome) {
+ var mcBiome = ((CraftServer) Bukkit.getServer()).getServer().registryAccess().registryOrThrow(Registries.BIOME).getKey(biome);
+ if (mcBiome == null) {
+ return null;
+ }
+ return BiomeType.REGISTRY.get(mcBiome.toString());
+ }
+
+ public net.minecraft.world.level.block.state.BlockState adapt(BlockState blockState) {
+ int internalId = BlockStateIdAccess.getBlockStateId(blockState);
+ return Block.stateById(internalId);
+ }
+
+ @Override
+ public BlockState getBlock(Location location) {
+ checkNotNull(location);
+
+ CraftWorld craftWorld = ((CraftWorld) location.getWorld());
+ int x = location.getBlockX();
+ int y = location.getBlockY();
+ int z = location.getBlockZ();
+
+ final ServerLevel handle = craftWorld.getHandle();
+ LevelChunk chunk = handle.getChunk(x >> 4, z >> 4);
+ final BlockPos blockPos = new BlockPos(x, y, z);
+ final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(blockPos);
+ return adapt(blockData);
+ }
+
+ @Override
+ public BaseBlock getFullBlock(Location location) {
+ BlockState state = getBlock(location);
+
+ CraftWorld craftWorld = ((CraftWorld) location.getWorld());
+ int x = location.getBlockX();
+ int y = location.getBlockY();
+ int z = location.getBlockZ();
+
+ final ServerLevel handle = craftWorld.getHandle();
+ LevelChunk chunk = handle.getChunk(x >> 4, z >> 4);
+ final BlockPos blockPos = new BlockPos(x, y, z);
+
+ // Read the NBT data
+ BlockEntity te = chunk.getBlockEntity(blockPos);
+ if (te != null) {
+ net.minecraft.nbt.CompoundTag tag = te.saveWithId(MinecraftServer.getServer().registryAccess());
+ return state.toBaseBlock(LazyReference.from(() -> (LinCompoundTag) toNative(tag)));
+ }
+
+ return state.toBaseBlock();
+ }
+
+ private static final HashMap> biomeTypeToNMSCache = new HashMap<>();
+ private static final HashMap, BiomeType> biomeTypeFromNMSCache = new HashMap<>();
+
+ @Override
+ public BiomeType getBiome(Location location) {
+ checkNotNull(location);
+
+ CraftWorld craftWorld = ((CraftWorld) location.getWorld());
+ int x = location.getBlockX();
+ int y = location.getBlockY();
+ int z = location.getBlockZ();
+
+ final ServerLevel handle = craftWorld.getHandle();
+ LevelChunk chunk = handle.getChunk(x >> 4, z >> 4);
+
+ return biomeTypeFromNMSCache.computeIfAbsent(chunk.getNoiseBiome(x >> 2, y >> 2, z >> 2), b -> BiomeType.REGISTRY.get(b.unwrapKey().get().location().toString()));
+ }
+
+ @Override
+ public void setBiome(Location location, BiomeType biome) {
+ checkNotNull(location);
+ checkNotNull(biome);
+
+ CraftWorld craftWorld = ((CraftWorld) location.getWorld());
+ int x = location.getBlockX();
+ int y = location.getBlockY();
+ int z = location.getBlockZ();
+
+ final ServerLevel handle = craftWorld.getHandle();
+ LevelChunk chunk = handle.getChunk(x >> 4, z >> 4);
+ chunk.setBiome(x >> 2, y >> 2, z >> 2, biomeTypeToNMSCache.computeIfAbsent(biome, b -> ((CraftServer) Bukkit.getServer()).getServer().registryAccess().registryOrThrow(Registries.BIOME).getHolderOrThrow(ResourceKey.create(Registries.BIOME, new ResourceLocation(b.id())))));
+ chunk.setUnsaved(true);
+ }
+
+ @Override
+ public WorldNativeAccess, ?, ?> createWorldNativeAccess(World world) {
+ return new PaperweightWorldNativeAccess(this, new WeakReference<>(((CraftWorld) world).getHandle()));
+ }
+
+ private static net.minecraft.core.Direction adapt(Direction face) {
+ switch (face) {
+ case NORTH:
+ return net.minecraft.core.Direction.NORTH;
+ case SOUTH:
+ return net.minecraft.core.Direction.SOUTH;
+ case WEST:
+ return net.minecraft.core.Direction.WEST;
+ case EAST:
+ return net.minecraft.core.Direction.EAST;
+ case DOWN:
+ return net.minecraft.core.Direction.DOWN;
+ case UP:
+ default:
+ return net.minecraft.core.Direction.UP;
+ }
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ private net.minecraft.world.level.block.state.BlockState applyProperties(
+ StateDefinition stateContainer,
+ net.minecraft.world.level.block.state.BlockState newState,
+ Map, Object> states
+ ) {
+ for (Map.Entry, Object> state : states.entrySet()) {
+ net.minecraft.world.level.block.state.properties.Property> property =
+ stateContainer.getProperty(state.getKey().getName());
+ Comparable> value = (Comparable) state.getValue();
+ // we may need to adapt this value, depending on the source prop
+ if (property instanceof DirectionProperty) {
+ Direction dir = (Direction) value;
+ value = adapt(dir);
+ } else if (property instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
+ String enumName = (String) value;
+ value = ((net.minecraft.world.level.block.state.properties.EnumProperty>) property)
+ .getValue(enumName).orElseThrow(() ->
+ new IllegalStateException(
+ "Enum property " + property.getName() + " does not contain " + enumName
+ )
+ );
+ }
+
+ newState = newState.setValue(
+ (net.minecraft.world.level.block.state.properties.Property) property,
+ (Comparable) value
+ );
+ }
+ return newState;
+ }
+
+ @Override
+ public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
+ checkNotNull(entity);
+
+ CraftEntity craftEntity = ((CraftEntity) entity);
+ Entity mcEntity = craftEntity.getHandle();
+
+ // Do not allow creating of passenger entity snapshots, passengers are included in the vehicle entity
+ if (mcEntity.isPassenger()) {
+ return null;
+ }
+
+ String id = getEntityId(mcEntity);
+
+ net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
+ readEntityIntoTag(mcEntity, tag);
+ return new BaseEntity(
+ EntityTypes.get(id),
+ LazyReference.from(() -> (LinCompoundTag) toNative(tag))
+ );
+ }
+
+ @Nullable
+ @Override
+ public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state) {
+ checkNotNull(location);
+ checkNotNull(state);
+
+ CraftWorld craftWorld = ((CraftWorld) location.getWorld());
+ ServerLevel worldServer = craftWorld.getHandle();
+
+ String entityId = state.getType().id();
+
+ LinCompoundTag nativeTag = state.getNbt();
+ net.minecraft.nbt.CompoundTag tag;
+ if (nativeTag != null) {
+ tag = (net.minecraft.nbt.CompoundTag) fromNative(nativeTag);
+ removeUnwantedEntityTagsRecursively(tag);
+ } else {
+ tag = new net.minecraft.nbt.CompoundTag();
+ }
+
+ tag.putString("id", entityId);
+
+ Entity createdEntity = EntityType.loadEntityRecursive(tag, craftWorld.getHandle(), (loadedEntity) -> {
+ loadedEntity.absMoveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
+ return loadedEntity;
+ });
+
+ if (createdEntity != null) {
+ worldServer.addFreshEntityWithPassengers(createdEntity, SpawnReason.CUSTOM);
+ return createdEntity.getBukkitEntity();
+ } else {
+ return null;
+ }
+ }
+
+ // This removes all unwanted tags from the main entity and all its passengers
+ private void removeUnwantedEntityTagsRecursively(net.minecraft.nbt.CompoundTag tag) {
+ for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
+ tag.remove(name);
+ }
+
+ // Adapted from net.minecraft.world.entity.EntityType#loadEntityRecursive
+ if (tag.contains("Passengers", LinTagId.LIST.id())) {
+ net.minecraft.nbt.ListTag nbttaglist = tag.getList("Passengers", LinTagId.COMPOUND.id());
+
+ for (int i = 0; i < nbttaglist.size(); ++i) {
+ removeUnwantedEntityTagsRecursively(nbttaglist.getCompound(i));
+ }
+ }
+ }
+
+ @Override
+ public Component getRichBlockName(BlockType blockType) {
+ return TranslatableComponent.of(getBlockFromType(blockType).getDescriptionId());
+ }
+
+ @Override
+ public Component getRichItemName(ItemType itemType) {
+ return TranslatableComponent.of(getItemFromType(itemType).getDescriptionId());
+ }
+
+ @Override
+ public Component getRichItemName(BaseItemStack itemStack) {
+ return TranslatableComponent.of(CraftItemStack.asNMSCopy(BukkitAdapter.adapt(itemStack)).getDescriptionId());
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private static final LoadingCache> PROPERTY_CACHE = CacheBuilder.newBuilder().build(new CacheLoader>() {
+ @Override
+ public Property> load(net.minecraft.world.level.block.state.properties.Property state) throws Exception {
+ if (state instanceof net.minecraft.world.level.block.state.properties.BooleanProperty) {
+ return new BooleanProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
+ } else if (state instanceof DirectionProperty) {
+ return new DirectionalProperty(state.getName(),
+ (List) state.getPossibleValues().stream().map(e -> Direction.valueOf(((StringRepresentable) e).getSerializedName().toUpperCase(Locale.ROOT))).toList());
+ } else if (state instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
+ return new EnumProperty(state.getName(),
+ (List) state.getPossibleValues().stream().map(e -> ((StringRepresentable) e).getSerializedName()).toList());
+ } else if (state instanceof net.minecraft.world.level.block.state.properties.IntegerProperty) {
+ return new IntegerProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
+ } else {
+ throw new IllegalArgumentException("WorldEdit needs an update to support " + state.getClass().getSimpleName());
+ }
+ }
+ });
+
+ @SuppressWarnings({ "rawtypes" })
+ @Override
+ public Map> getProperties(BlockType blockType) {
+ Map> properties = new TreeMap<>();
+ Block block = getBlockFromType(blockType);
+ StateDefinition blockStateList =
+ block.getStateDefinition();
+ for (net.minecraft.world.level.block.state.properties.Property state : blockStateList.getProperties()) {
+ Property> property = PROPERTY_CACHE.getUnchecked(state);
+ properties.put(property.getName(), property);
+ }
+ return properties;
+ }
+
+ @Override
+ public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData) {
+ var structureBlock = new StructureBlockEntity(
+ new BlockPos(pos.x(), pos.y(), pos.z()),
+ Blocks.STRUCTURE_BLOCK.defaultBlockState()
+ );
+ structureBlock.setLevel(((CraftPlayer) player).getHandle().level());
+ ((CraftPlayer) player).getHandle().connection.send(ClientboundBlockEntityDataPacket.create(
+ structureBlock,
+ (blockEntity, registryAccess) -> (net.minecraft.nbt.CompoundTag) fromNative(nbtData)
+ ));
+ }
+
+ @Override
+ public void sendFakeOP(Player player) {
+ ((CraftPlayer) player).getHandle().connection.send(new ClientboundEntityEventPacket(
+ ((CraftPlayer) player).getHandle(), (byte) 28
+ ));
+ }
+
+ /**
+ * For serializing and deserializing components.
+ */
+ private static final Codec COMPONENTS_CODEC = DataComponentPatch.CODEC.optionalFieldOf(
+ "components", DataComponentPatch.EMPTY
+ ).codec();
+
+ @Override
+ public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
+ var registryAccess = DedicatedServer.getServer().registryAccess();
+ ItemStack stack = new ItemStack(
+ registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(baseItemStack.getType().id())),
+ baseItemStack.getAmount()
+ );
+ LinCompoundTag nbt = baseItemStack.getNbt();
+ if (nbt != null) {
+ DataComponentPatch componentPatch = COMPONENTS_CODEC.parse(
+ registryAccess.createSerializationContext(NbtOps.INSTANCE),
+ fromNative(nbt)
+ ).getOrThrow();
+ stack.applyComponents(componentPatch);
+ }
+ return CraftItemStack.asCraftMirror(stack);
+ }
+
+ @Override
+ public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) {
+ var registryAccess = DedicatedServer.getServer().registryAccess();
+ final ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
+ CompoundTag tag = (CompoundTag) COMPONENTS_CODEC.encodeStart(
+ registryAccess.createSerializationContext(NbtOps.INSTANCE),
+ nmsStack.getComponentsPatch()
+ ).getOrThrow();
+ return new BaseItemStack(BukkitAdapter.asItemType(itemStack.getType()), LazyReference.from(() -> (LinCompoundTag) toNative(tag)), itemStack.getAmount());
+ }
+
+ private final LoadingCache fakePlayers
+ = CacheBuilder.newBuilder().weakKeys().softValues().build(CacheLoader.from(PaperweightFakePlayer::new));
+
+ @Override
+ public boolean simulateItemUse(World world, BlockVector3 position, BaseItem item, Direction face) {
+ CraftWorld craftWorld = (CraftWorld) world;
+ ServerLevel worldServer = craftWorld.getHandle();
+ ItemStack stack = CraftItemStack.asNMSCopy(adapt(
+ item instanceof BaseItemStack
+ ? ((BaseItemStack) item)
+ : new BaseItemStack(item.getType(), item.getNbtReference(), 1)
+ ));
+
+ PaperweightFakePlayer fakePlayer;
+ try {
+ fakePlayer = fakePlayers.get(worldServer);
+ } catch (ExecutionException ignored) {
+ return false;
+ }
+ fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, stack);
+ fakePlayer.absMoveTo(position.x(), position.y(), position.z(),
+ (float) face.toVector().toYaw(), (float) face.toVector().toPitch());
+
+ final BlockPos blockPos = new BlockPos(position.x(), position.y(), position.z());
+ final Vec3 blockVec = Vec3.atLowerCornerOf(blockPos);
+ final net.minecraft.core.Direction enumFacing = adapt(face);
+ BlockHitResult rayTrace = new BlockHitResult(blockVec, enumFacing, blockPos, false);
+ UseOnContext context = new UseOnContext(fakePlayer, InteractionHand.MAIN_HAND, rayTrace);
+ InteractionResult result = stack.useOn(context);
+ if (result != InteractionResult.SUCCESS) {
+ if (worldServer.getBlockState(blockPos).useItemOn(stack, worldServer, fakePlayer, InteractionHand.MAIN_HAND, rayTrace).consumesAction()) {
+ result = InteractionResult.SUCCESS;
+ } else {
+ result = stack.getItem().use(worldServer, fakePlayer, InteractionHand.MAIN_HAND).getResult();
+ }
+ }
+
+ return result == InteractionResult.SUCCESS;
+ }
+
+ @Override
+ public boolean canPlaceAt(World world, BlockVector3 position, BlockState blockState) {
+ int internalId = BlockStateIdAccess.getBlockStateId(blockState);
+ net.minecraft.world.level.block.state.BlockState blockData = Block.stateById(internalId);
+ return blockData.canSurvive(((CraftWorld) world).getHandle(), new BlockPos(position.x(), position.y(), position.z()));
+ }
+
+ @Override
+ public boolean regenerate(World bukkitWorld, Region region, Extent extent, RegenOptions options) {
+ try {
+ doRegen(bukkitWorld, region, extent, options);
+ } catch (Exception e) {
+ throw new IllegalStateException("Regen failed.", e);
+ }
+
+ return true;
+ }
+
+ private void doRegen(World bukkitWorld, Region region, Extent extent, RegenOptions options) throws Exception {
+ Environment env = bukkitWorld.getEnvironment();
+ ChunkGenerator gen = bukkitWorld.getGenerator();
+
+ Path tempDir = Files.createTempDirectory("WorldEditWorldGen");
+ LevelStorageSource levelStorage = LevelStorageSource.createDefault(tempDir);
+ ResourceKey worldDimKey = getWorldDimKey(env);
+ try (LevelStorageSource.LevelStorageAccess session = levelStorage.createAccess("worldeditregentempworld", worldDimKey)) {
+ ServerLevel originalWorld = ((CraftWorld) bukkitWorld).getHandle();
+ PrimaryLevelData levelProperties = (PrimaryLevelData) originalWorld.getServer()
+ .getWorldData().overworldData();
+ WorldOptions originalOpts = levelProperties.worldGenOptions();
+
+ long seed = options.getSeed().orElse(originalWorld.getSeed());
+ WorldOptions newOpts = options.getSeed().isPresent()
+ ? originalOpts.withSeed(OptionalLong.of(seed))
+ : originalOpts;
+
+ LevelSettings newWorldSettings = new LevelSettings(
+ "worldeditregentempworld",
+ levelProperties.settings.gameType(),
+ levelProperties.settings.hardcore(),
+ levelProperties.settings.difficulty(),
+ levelProperties.settings.allowCommands(),
+ levelProperties.settings.gameRules(),
+ levelProperties.settings.getDataConfiguration()
+ );
+
+ @SuppressWarnings("deprecation")
+ PrimaryLevelData.SpecialWorldProperty specialWorldProperty =
+ levelProperties.isFlatWorld()
+ ? PrimaryLevelData.SpecialWorldProperty.FLAT
+ : levelProperties.isDebugWorld()
+ ? PrimaryLevelData.SpecialWorldProperty.DEBUG
+ : PrimaryLevelData.SpecialWorldProperty.NONE;
+
+ PrimaryLevelData newWorldData = new PrimaryLevelData(newWorldSettings, newOpts, specialWorldProperty, Lifecycle.stable());
+
+ ServerLevel freshWorld = new ServerLevel(
+ originalWorld.getServer(),
+ originalWorld.getServer().executor,
+ session, newWorldData,
+ originalWorld.dimension(),
+ new LevelStem(
+ originalWorld.dimensionTypeRegistration(),
+ originalWorld.getChunkSource().getGenerator()
+ ),
+ new NoOpWorldLoadListener(),
+ originalWorld.isDebug(),
+ seed,
+ ImmutableList.of(),
+ false,
+ originalWorld.getRandomSequences(),
+ env,
+ gen,
+ bukkitWorld.getBiomeProvider()
+ );
+ try {
+ regenForWorld(region, extent, freshWorld, options);
+ } finally {
+ freshWorld.getChunkSource().close(false);
+ }
+ } finally {
+ try {
+ @SuppressWarnings("unchecked")
+ Map map = (Map) serverWorldsField.get(Bukkit.getServer());
+ map.remove("worldeditregentempworld");
+ } catch (IllegalAccessException ignored) {
+ }
+ SafeFiles.tryHardToDeleteDir(tempDir);
+ }
+ }
+
+ private BiomeType adapt(ServerLevel serverWorld, Biome origBiome) {
+ ResourceLocation key = serverWorld.registryAccess().registryOrThrow(Registries.BIOME).getKey(origBiome);
+ if (key == null) {
+ return null;
+ }
+ return BiomeTypes.get(key.toString());
+ }
+
+ @SuppressWarnings("unchecked")
+ private void regenForWorld(Region region, Extent extent, ServerLevel serverWorld, RegenOptions options) throws WorldEditException {
+ List> chunkLoadings = submitChunkLoadTasks(region, serverWorld);
+ BlockableEventLoop executor;
+ try {
+ executor = (BlockableEventLoop) chunkProviderExecutorField.get(serverWorld.getChunkSource());
+ } catch (IllegalAccessException e) {
+ throw new IllegalStateException("Couldn't get executor for chunk loading.", e);
+ }
+ executor.managedBlock(() -> {
+ // bail out early if a future fails
+ if (chunkLoadings.stream().anyMatch(ftr ->
+ ftr.isDone() && Futures.getUnchecked(ftr) == null
+ )) {
+ return false;
+ }
+ return chunkLoadings.stream().allMatch(CompletableFuture::isDone);
+ });
+ Map chunks = new HashMap<>();
+ for (CompletableFuture future : chunkLoadings) {
+ @Nullable
+ ChunkAccess chunk = future.getNow(null);
+ checkState(chunk != null, "Failed to generate a chunk, regen failed.");
+ chunks.put(chunk.getPos(), chunk);
+ }
+
+ for (BlockVector3 vec : region) {
+ BlockPos pos = new BlockPos(vec.x(), vec.y(), vec.z());
+ ChunkAccess chunk = chunks.get(new ChunkPos(pos));
+ final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(pos);
+ int internalId = Block.getId(blockData);
+ BlockStateHolder> state = BlockStateIdAccess.getBlockStateById(internalId);
+ Objects.requireNonNull(state);
+ BlockEntity blockEntity = chunk.getBlockEntity(pos);
+ if (blockEntity != null) {
+ net.minecraft.nbt.CompoundTag tag = blockEntity.saveWithId(serverWorld.registryAccess());
+ state = state.toBaseBlock(LazyReference.from(() -> (LinCompoundTag) toNative(tag)));
+ }
+ extent.setBlock(vec, state.toBaseBlock());
+ if (options.shouldRegenBiomes()) {
+ Biome origBiome = chunk.getNoiseBiome(vec.x(), vec.y(), vec.z()).value();
+ BiomeType adaptedBiome = adapt(serverWorld, origBiome);
+ if (adaptedBiome != null) {
+ extent.setBiome(vec, adaptedBiome);
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private List> submitChunkLoadTasks(Region region, ServerLevel serverWorld) {
+ ServerChunkCache chunkManager = serverWorld.getChunkSource();
+ List> chunkLoadings = new ArrayList<>();
+ // Pre-gen all the chunks
+ for (BlockVector2 chunk : region.getChunks()) {
+ try {
+ //noinspection unchecked
+ chunkLoadings.add(
+ ((CompletableFuture>)
+ getChunkFutureMethod.invoke(chunkManager, chunk.x(), chunk.z(), ChunkStatus.FEATURES, true))
+ .thenApply(either -> either.orElse(null))
+ );
+ } catch (IllegalAccessException | InvocationTargetException e) {
+ throw new IllegalStateException("Couldn't load chunk for regen.", e);
+ }
+ }
+ return chunkLoadings;
+ }
+
+ private ResourceKey getWorldDimKey(Environment env) {
+ switch (env) {
+ case NETHER:
+ return LevelStem.NETHER;
+ case THE_END:
+ return LevelStem.END;
+ case NORMAL:
+ default:
+ return LevelStem.OVERWORLD;
+ }
+ }
+
+ private static final Set SUPPORTED_SIDE_EFFECTS = Sets.immutableEnumSet(
+ SideEffect.NEIGHBORS,
+ SideEffect.LIGHTING,
+ SideEffect.VALIDATION,
+ SideEffect.ENTITY_AI,
+ SideEffect.EVENTS,
+ SideEffect.UPDATE
+ );
+
+ @Override
+ public Set getSupportedSideEffects() {
+ return SUPPORTED_SIDE_EFFECTS;
+ }
+
+ @Override
+ public boolean clearContainerBlockContents(World world, BlockVector3 pt) {
+ ServerLevel originalWorld = ((CraftWorld) world).getHandle();
+
+ BlockEntity entity = originalWorld.getBlockEntity(new BlockPos(pt.x(), pt.y(), pt.z()));
+ if (entity instanceof Clearable) {
+ ((Clearable) entity).clearContent();
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void initializeRegistries() {
+ DedicatedServer server = ((CraftServer) Bukkit.getServer()).getServer();
+ // Biomes
+ for (ResourceLocation name : server.registryAccess().registryOrThrow(Registries.BIOME).keySet()) {
+ if (BiomeType.REGISTRY.get(name.toString()) == null) {
+ BiomeType.REGISTRY.register(name.toString(), new BiomeType(name.toString()));
+ }
+ }
+
+ // Features
+ for (ResourceLocation name: server.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).keySet()) {
+ if (ConfiguredFeatureType.REGISTRY.get(name.toString()) == null) {
+ ConfiguredFeatureType.REGISTRY.register(name.toString(), new ConfiguredFeatureType(name.toString()));
+ }
+ }
+
+ // Structures
+ for (ResourceLocation name : server.registryAccess().registryOrThrow(Registries.STRUCTURE).keySet()) {
+ if (StructureType.REGISTRY.get(name.toString()) == null) {
+ StructureType.REGISTRY.register(name.toString(), new StructureType(name.toString()));
+ }
+ }
+
+ // BiomeCategories
+ Registry biomeRegistry = server.registryAccess().registryOrThrow(Registries.BIOME);
+ biomeRegistry.getTagNames().forEach(tagKey -> {
+ String key = tagKey.location().toString();
+ if (BiomeCategory.REGISTRY.get(key) == null) {
+ BiomeCategory.REGISTRY.register(key, new BiomeCategory(
+ key,
+ () -> biomeRegistry.getTag(tagKey)
+ .stream()
+ .flatMap(HolderSet.Named::stream)
+ .map(Holder::value)
+ .map(this::adapt)
+ .collect(Collectors.toSet()))
+ );
+ }
+ });
+ }
+
+ public boolean generateFeature(ConfiguredFeatureType type, World world, EditSession session, BlockVector3 pt) {
+ ServerLevel originalWorld = ((CraftWorld) world).getHandle();
+ ConfiguredFeature, ?> k = originalWorld.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).get(ResourceLocation.tryParse(type.id()));
+ ServerChunkCache chunkManager = originalWorld.getChunkSource();
+ WorldGenLevel proxyLevel = PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this);
+ return k != null && k.place(proxyLevel, chunkManager.getGenerator(), random, new BlockPos(pt.x(), pt.y(), pt.z()));
+ }
+
+ public boolean generateStructure(StructureType type, World world, EditSession session, BlockVector3 pt) {
+ ServerLevel originalWorld = ((CraftWorld) world).getHandle();
+ Structure k = originalWorld.registryAccess().registryOrThrow(Registries.STRUCTURE).get(ResourceLocation.tryParse(type.id()));
+ if (k == null) {
+ return false;
+ }
+
+ ServerChunkCache chunkManager = originalWorld.getChunkSource();
+ WorldGenLevel proxyLevel = PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this);
+ ChunkPos chunkPos = new ChunkPos(new BlockPos(pt.x(), pt.y(), pt.z()));
+ StructureStart structureStart = k.generate(originalWorld.registryAccess(), chunkManager.getGenerator(), chunkManager.getGenerator().getBiomeSource(), chunkManager.randomState(), originalWorld.getStructureManager(), originalWorld.getSeed(), chunkPos, 0, proxyLevel, biome -> true);
+
+ if (!structureStart.isValid()) {
+ return false;
+ } else {
+ BoundingBox boundingBox = structureStart.getBoundingBox();
+ ChunkPos min = new ChunkPos(SectionPos.blockToSectionCoord(boundingBox.minX()), SectionPos.blockToSectionCoord(boundingBox.minZ()));
+ ChunkPos max = new ChunkPos(SectionPos.blockToSectionCoord(boundingBox.maxX()), SectionPos.blockToSectionCoord(boundingBox.maxZ()));
+ ChunkPos.rangeClosed(min, max).forEach((chunkPosx) -> structureStart.placeInChunk(proxyLevel, originalWorld.structureManager(), chunkManager.getGenerator(), originalWorld.getRandom(), new BoundingBox(chunkPosx.getMinBlockX(), originalWorld.getMinBuildHeight(), chunkPosx.getMinBlockZ(), chunkPosx.getMaxBlockX(), originalWorld.getMaxBuildHeight(), chunkPosx.getMaxBlockZ()), chunkPosx));
+ return true;
+ }
+ }
+
+ @Override
+ public void sendBiomeUpdates(World world, Iterable chunks) {
+ ServerLevel originalWorld = ((CraftWorld) world).getHandle();
+
+ List nativeChunks = chunks instanceof Collection chunkCollection ? Lists.newArrayListWithCapacity(chunkCollection.size()) : Lists.newArrayList();
+ for (BlockVector2 chunk : chunks) {
+ nativeChunks.add(originalWorld.getChunk(chunk.x(), chunk.z(), ChunkStatus.BIOMES, false));
+ }
+ originalWorld.getChunkSource().chunkMap.resendBiomesForChunks(nativeChunks);
+ }
+
+ // ------------------------------------------------------------------------
+ // Code that is less likely to break
+ // ------------------------------------------------------------------------
+
+ /**
+ * Converts from a non-native NMS NBT structure to a native WorldEdit NBT
+ * structure.
+ *
+ * @param foreign non-native NMS NBT structure
+ * @return native WorldEdit NBT structure
+ */
+ LinTag> toNative(net.minecraft.nbt.Tag foreign) {
+ if (foreign == null) {
+ return null;
+ }
+ if (foreign instanceof net.minecraft.nbt.CompoundTag compoundTag) {
+ LinCompoundTag.Builder builder = LinCompoundTag.builder();
+ for (var entry : compoundTag.getAllKeys()) {
+ builder.put(entry, toNative(compoundTag.get(entry)));
+ }
+ return builder.build();
+ } else if (foreign instanceof net.minecraft.nbt.ByteTag byteTag) {
+ return LinByteTag.of(byteTag.getAsByte());
+ } else if (foreign instanceof net.minecraft.nbt.ByteArrayTag byteArrayTag) {
+ return LinByteArrayTag.of(byteArrayTag.getAsByteArray());
+ } else if (foreign instanceof net.minecraft.nbt.DoubleTag doubleTag) {
+ return LinDoubleTag.of(doubleTag.getAsDouble());
+ } else if (foreign instanceof net.minecraft.nbt.FloatTag floatTag) {
+ return LinFloatTag.of(floatTag.getAsFloat());
+ } else if (foreign instanceof net.minecraft.nbt.IntTag intTag) {
+ return LinIntTag.of(intTag.getAsInt());
+ } else if (foreign instanceof net.minecraft.nbt.IntArrayTag intArrayTag) {
+ return LinIntArrayTag.of(intArrayTag.getAsIntArray());
+ } else if (foreign instanceof net.minecraft.nbt.LongArrayTag longArrayTag) {
+ return LinLongArrayTag.of(longArrayTag.getAsLongArray());
+ } else if (foreign instanceof net.minecraft.nbt.ListTag listTag) {
+ try {
+ return toNativeList(listTag);
+ } catch (Throwable e) {
+ logger.log(Level.WARNING, "Failed to convert net.minecraft.nbt.ListTag", e);
+ return LinListTag.empty(LinTagType.endTag());
+ }
+ } else if (foreign instanceof net.minecraft.nbt.LongTag longTag) {
+ return LinLongTag.of(longTag.getAsLong());
+ } else if (foreign instanceof net.minecraft.nbt.ShortTag shortTag) {
+ return LinShortTag.of(shortTag.getAsShort());
+ } else if (foreign instanceof net.minecraft.nbt.StringTag stringTag) {
+ return LinStringTag.of(stringTag.getAsString());
+ } else if (foreign instanceof net.minecraft.nbt.EndTag) {
+ return LinEndTag.instance();
+ } else {
+ throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName());
+ }
+ }
+
+ /**
+ * Convert a foreign NBT list tag into a native WorldEdit one.
+ *
+ * @param foreign the foreign tag
+ * @return the converted tag
+ * @throws SecurityException on error
+ * @throws IllegalArgumentException on error
+ */
+ private LinListTag> toNativeList(net.minecraft.nbt.ListTag foreign) throws SecurityException, IllegalArgumentException {
+ LinListTag.Builder> builder = LinListTag.builder(
+ LinTagType.fromId(LinTagId.fromId(foreign.getElementType()))
+ );
+
+ for (net.minecraft.nbt.Tag tag : foreign) {
+ builder.add(toNative(tag));
+ }
+
+ return builder.build();
+ }
+
+ /**
+ * Converts a WorldEdit-native NBT structure to a NMS structure.
+ *
+ * @param foreign structure to convert
+ * @return non-native structure
+ */
+ Tag fromNative(LinTag> foreign) {
+ if (foreign == null) {
+ return null;
+ }
+ if (foreign instanceof LinCompoundTag compoundTag) {
+ net.minecraft.nbt.CompoundTag tag = new CompoundTag();
+ for (var entry : compoundTag.value().entrySet()) {
+ tag.put(entry.getKey(), fromNative(entry.getValue()));
+ }
+ return tag;
+ } else if (foreign instanceof LinByteTag byteTag) {
+ return ByteTag.valueOf(byteTag.valueAsByte());
+ } else if (foreign instanceof LinByteArrayTag byteArrayTag) {
+ return new ByteArrayTag(byteArrayTag.value());
+ } else if (foreign instanceof LinDoubleTag doubleTag) {
+ return DoubleTag.valueOf(doubleTag.valueAsDouble());
+ } else if (foreign instanceof LinFloatTag floatTag) {
+ return FloatTag.valueOf(floatTag.valueAsFloat());
+ } else if (foreign instanceof LinIntTag intTag) {
+ return IntTag.valueOf(intTag.valueAsInt());
+ } else if (foreign instanceof LinIntArrayTag intArrayTag) {
+ return new IntArrayTag(intArrayTag.value());
+ } else if (foreign instanceof LinLongArrayTag longArrayTag) {
+ return new LongArrayTag(longArrayTag.value());
+ } else if (foreign instanceof LinListTag> listTag) {
+ net.minecraft.nbt.ListTag tag = new ListTag();
+ for (var t : listTag.value()) {
+ tag.add(fromNative(t));
+ }
+ return tag;
+ } else if (foreign instanceof LinLongTag longTag) {
+ return LongTag.valueOf(longTag.valueAsLong());
+ } else if (foreign instanceof LinShortTag shortTag) {
+ return ShortTag.valueOf(shortTag.valueAsShort());
+ } else if (foreign instanceof LinStringTag stringTag) {
+ return StringTag.valueOf(stringTag.value());
+ } else if (foreign instanceof LinEndTag) {
+ return EndTag.INSTANCE;
+ } else {
+ throw new IllegalArgumentException("Don't know how to make NMS " + foreign.getClass().getCanonicalName());
+ }
+ }
+
+ @Override
+ public boolean supportsWatchdog() {
+ return watchdog != null;
+ }
+
+ @Override
+ public void tickWatchdog() {
+ watchdog.tick();
+ }
+
+ private class SpigotWatchdog implements Watchdog {
+ private final Field instanceField;
+ private final Field lastTickField;
+
+ SpigotWatchdog() throws NoSuchFieldException {
+ Field instanceField = WatchdogThread.class.getDeclaredField("instance");
+ instanceField.setAccessible(true);
+ this.instanceField = instanceField;
+
+ Field lastTickField = WatchdogThread.class.getDeclaredField("lastTick");
+ lastTickField.setAccessible(true);
+ this.lastTickField = lastTickField;
+ }
+
+ @Override
+ public void tick() {
+ try {
+ WatchdogThread instance = (WatchdogThread) this.instanceField.get(null);
+ if ((long) lastTickField.get(instance) != 0) {
+ WatchdogThread.tick();
+ }
+ } catch (IllegalAccessException e) {
+ logger.log(Level.WARNING, "Failed to tick watchdog", e);
+ }
+ }
+ }
+
+ private static class MojangWatchdog implements Watchdog {
+ private final DedicatedServer server;
+ private final Field tickField;
+
+ MojangWatchdog(DedicatedServer server) throws NoSuchFieldException {
+ this.server = server;
+ Field tickField = MinecraftServer.class.getDeclaredField(
+ Refraction.pickName("nextTickTime", "ag")
+ );
+ if (tickField.getType() != long.class) {
+ throw new IllegalStateException("nextTickTime is not a long field, mapping is likely incorrect");
+ }
+ tickField.setAccessible(true);
+ this.tickField = tickField;
+ }
+
+ @Override
+ public void tick() {
+ try {
+ tickField.set(server, Util.getMillis());
+ } catch (IllegalAccessException ignored) {
+ }
+ }
+ }
+
+ private static class NoOpWorldLoadListener implements ChunkProgressListener {
+ @Override
+ public void updateSpawnPos(ChunkPos spawnPos) {
+ }
+
+ @Override
+ public void onStatusChange(ChunkPos pos, @org.jetbrains.annotations.Nullable ChunkStatus status) {
+ }
+
+ @Override
+ public void start() {
+ }
+
+ @Override
+ public void stop() {
+ }
+
+ }
+}
diff --git a/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightDataConverters.java b/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightDataConverters.java
new file mode 100644
index 0000000000..4ad9244e2c
--- /dev/null
+++ b/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightDataConverters.java
@@ -0,0 +1,2803 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.bukkit.adapter.impl.v1_20_R4;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+import com.mojang.datafixers.DSL.TypeReference;
+import com.mojang.datafixers.DataFixer;
+import com.mojang.datafixers.DataFixerBuilder;
+import com.mojang.datafixers.schemas.Schema;
+import com.mojang.serialization.Dynamic;
+import net.minecraft.core.Direction;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.FloatTag;
+import net.minecraft.nbt.ListTag;
+import net.minecraft.nbt.NbtOps;
+import net.minecraft.nbt.StringTag;
+import net.minecraft.nbt.Tag;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.MutableComponent;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.util.GsonHelper;
+import net.minecraft.util.StringUtil;
+import net.minecraft.util.datafix.DataFixers;
+import net.minecraft.util.datafix.fixes.References;
+import net.minecraft.world.item.DyeColor;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.enginehub.linbus.tree.LinCompoundTag;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.Executor;
+import java.util.stream.Collectors;
+import javax.annotation.Nullable;
+
+/**
+ * Handles converting all Pre 1.13.2 data using the Legacy DataFix System (ported to 1.13.2)
+ *
+ * We register a DFU Fixer per Legacy Data Version and apply the fixes using legacy strategy
+ * which is safer, faster and cleaner code.
+ *
+ * The pre DFU code did not fail when the Source version was unknown.
+ *
+ * This class also provides util methods for converting compounds to wrap the update call to
+ * receive the source version in the compound
+ */
+@SuppressWarnings({ "rawtypes", "unchecked" })
+class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.worldedit.world.DataFixer {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T fixUp(FixType type, T original, int srcVer) {
+ if (type == FixTypes.CHUNK) {
+ return (T) fixChunk((LinCompoundTag) original, srcVer);
+ } else if (type == FixTypes.BLOCK_ENTITY) {
+ return (T) fixBlockEntity((LinCompoundTag) original, srcVer);
+ } else if (type == FixTypes.ENTITY) {
+ return (T) fixEntity((LinCompoundTag) original, srcVer);
+ } else if (type == FixTypes.BLOCK_STATE) {
+ return (T) fixBlockState((String) original, srcVer);
+ } else if (type == FixTypes.ITEM_TYPE) {
+ return (T) fixItemType((String) original, srcVer);
+ } else if (type == FixTypes.BIOME) {
+ return (T) fixBiome((String) original, srcVer);
+ }
+ return original;
+ }
+
+ private LinCompoundTag fixChunk(LinCompoundTag originalChunk, int srcVer) {
+ CompoundTag tag = (CompoundTag) adapter.fromNative(originalChunk);
+ CompoundTag fixed = convert(LegacyType.CHUNK, tag, srcVer);
+ return (LinCompoundTag) adapter.toNative(fixed);
+ }
+
+ private LinCompoundTag fixBlockEntity(LinCompoundTag origTileEnt, int srcVer) {
+ CompoundTag tag = (CompoundTag) adapter.fromNative(origTileEnt);
+ CompoundTag fixed = convert(LegacyType.BLOCK_ENTITY, tag, srcVer);
+ return (LinCompoundTag) adapter.toNative(fixed);
+ }
+
+ private LinCompoundTag fixEntity(LinCompoundTag origEnt, int srcVer) {
+ CompoundTag tag = (CompoundTag) adapter.fromNative(origEnt);
+ CompoundTag fixed = convert(LegacyType.ENTITY, tag, srcVer);
+ return (LinCompoundTag) adapter.toNative(fixed);
+ }
+
+ private String fixBlockState(String blockState, int srcVer) {
+ CompoundTag stateNBT = stateToNBT(blockState);
+ Dynamic dynamic = new Dynamic<>(OPS_NBT, stateNBT);
+ CompoundTag fixed = (CompoundTag) INSTANCE.fixer.update(References.BLOCK_STATE, dynamic, srcVer, DATA_VERSION).getValue();
+ return nbtToState(fixed);
+ }
+
+ private String nbtToState(CompoundTag tagCompound) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(tagCompound.getString("Name"));
+ if (tagCompound.contains("Properties", 10)) {
+ sb.append('[');
+ CompoundTag props = tagCompound.getCompound("Properties");
+ sb.append(props.getAllKeys().stream().map(k -> k + "=" + props.getString(k).replace("\"", "")).collect(Collectors.joining(",")));
+ sb.append(']');
+ }
+ return sb.toString();
+ }
+
+ private static CompoundTag stateToNBT(String blockState) {
+ int propIdx = blockState.indexOf('[');
+ CompoundTag tag = new CompoundTag();
+ if (propIdx < 0) {
+ tag.putString("Name", blockState);
+ } else {
+ tag.putString("Name", blockState.substring(0, propIdx));
+ CompoundTag propTag = new CompoundTag();
+ String props = blockState.substring(propIdx + 1, blockState.length() - 1);
+ String[] propArr = props.split(",");
+ for (String pair : propArr) {
+ final String[] split = pair.split("=");
+ propTag.putString(split[0], split[1]);
+ }
+ tag.put("Properties", propTag);
+ }
+ return tag;
+ }
+
+ private String fixBiome(String key, int srcVer) {
+ return fixName(key, srcVer, References.BIOME);
+ }
+
+ private String fixItemType(String key, int srcVer) {
+ return fixName(key, srcVer, References.ITEM_NAME);
+ }
+
+ private static String fixName(String key, int srcVer, TypeReference type) {
+ return INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, StringTag.valueOf(key)), srcVer, DATA_VERSION)
+ .getValue().getAsString();
+ }
+
+ private final PaperweightAdapter adapter;
+
+ private static final NbtOps OPS_NBT = NbtOps.INSTANCE;
+ private static final int LEGACY_VERSION = 1343;
+ private static int DATA_VERSION;
+ static PaperweightDataConverters INSTANCE;
+
+ private final Map> converters = new EnumMap<>(LegacyType.class);
+ private final Map> inspectors = new EnumMap<>(LegacyType.class);
+
+ // Set on build
+ private DataFixer fixer;
+ private static final Map DFU_TO_LEGACY = new HashMap<>();
+
+ public enum LegacyType {
+ LEVEL(References.LEVEL),
+ PLAYER(References.PLAYER),
+ CHUNK(References.CHUNK),
+ BLOCK_ENTITY(References.BLOCK_ENTITY),
+ ENTITY(References.ENTITY),
+ ITEM_INSTANCE(References.ITEM_STACK),
+ OPTIONS(References.OPTIONS),
+ STRUCTURE(References.STRUCTURE);
+
+ private final TypeReference type;
+
+ LegacyType(TypeReference type) {
+ this.type = type;
+ DFU_TO_LEGACY.put(type.typeName(), this);
+ }
+
+ public TypeReference getDFUType() {
+ return type;
+ }
+ }
+
+ PaperweightDataConverters(int dataVersion, PaperweightAdapter adapter) {
+ super(dataVersion);
+ DATA_VERSION = dataVersion;
+ INSTANCE = this;
+ this.adapter = adapter;
+ registerConverters();
+ registerInspectors();
+ }
+
+
+ // Called after fixers are built and ready for FIXING
+ @Override
+ public DataFixer buildUnoptimized() {
+ return this.fixer = new WrappedDataFixer(DataFixers.getDataFixer());
+ }
+
+ @Override
+ public DataFixer buildOptimized(final Set requiredTypes, Executor executor) {
+ return buildUnoptimized();
+ }
+
+ @SuppressWarnings("unchecked")
+ private class WrappedDataFixer implements DataFixer {
+ private final DataFixer realFixer;
+
+ WrappedDataFixer(DataFixer realFixer) {
+ this.realFixer = realFixer;
+ }
+
+ @Override
+ public Dynamic update(TypeReference type, Dynamic dynamic, int sourceVer, int targetVer) {
+ LegacyType legacyType = DFU_TO_LEGACY.get(type.typeName());
+ if (sourceVer < LEGACY_VERSION && legacyType != null) {
+ CompoundTag cmp = (CompoundTag) dynamic.getValue();
+ int desiredVersion = Math.min(targetVer, LEGACY_VERSION);
+
+ cmp = convert(legacyType, cmp, sourceVer, desiredVersion);
+ sourceVer = desiredVersion;
+ dynamic = new Dynamic(OPS_NBT, cmp);
+ }
+ return realFixer.update(type, dynamic, sourceVer, targetVer);
+ }
+
+ private CompoundTag convert(LegacyType type, CompoundTag cmp, int sourceVer, int desiredVersion) {
+ List converters = PaperweightDataConverters.this.converters.get(type);
+ if (converters != null && !converters.isEmpty()) {
+ for (DataConverter converter : converters) {
+ int dataVersion = converter.getDataVersion();
+ if (dataVersion > sourceVer && dataVersion <= desiredVersion) {
+ cmp = converter.convert(cmp);
+ }
+ }
+ }
+
+ List inspectors = PaperweightDataConverters.this.inspectors.get(type);
+ if (inspectors != null && !inspectors.isEmpty()) {
+ for (DataInspector inspector : inspectors) {
+ cmp = inspector.inspect(cmp, sourceVer, desiredVersion);
+ }
+ }
+
+ return cmp;
+ }
+
+ @Override
+ public Schema getSchema(int i) {
+ return realFixer.getSchema(i);
+ }
+ }
+
+ public static CompoundTag convert(LegacyType type, CompoundTag cmp) {
+ return convert(type.getDFUType(), cmp);
+ }
+
+ public static CompoundTag convert(LegacyType type, CompoundTag cmp, int sourceVer) {
+ return convert(type.getDFUType(), cmp, sourceVer);
+ }
+
+ public static CompoundTag convert(LegacyType type, CompoundTag cmp, int sourceVer, int targetVer) {
+ return convert(type.getDFUType(), cmp, sourceVer, targetVer);
+ }
+
+ public static CompoundTag convert(TypeReference type, CompoundTag cmp) {
+ int i = cmp.contains("DataVersion", 99) ? cmp.getInt("DataVersion") : -1;
+ return convert(type, cmp, i);
+ }
+
+ public static CompoundTag convert(TypeReference type, CompoundTag cmp, int sourceVer) {
+ return convert(type, cmp, sourceVer, DATA_VERSION);
+ }
+
+ public static CompoundTag convert(TypeReference type, CompoundTag cmp, int sourceVer, int targetVer) {
+ if (sourceVer >= targetVer) {
+ return cmp;
+ }
+ return (CompoundTag) INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, cmp), sourceVer, targetVer).getValue();
+ }
+
+
+ public interface DataInspector {
+ CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer);
+ }
+
+ public interface DataConverter {
+
+ int getDataVersion();
+
+ CompoundTag convert(CompoundTag cmp);
+ }
+
+
+ private void registerInspector(LegacyType type, DataInspector inspector) {
+ this.inspectors.computeIfAbsent(type, k -> new ArrayList<>()).add(inspector);
+ }
+
+ private void registerConverter(LegacyType type, DataConverter converter) {
+ int version = converter.getDataVersion();
+
+ List list = this.converters.computeIfAbsent(type, k -> new ArrayList<>());
+ if (!list.isEmpty() && list.get(list.size() - 1).getDataVersion() > version) {
+ for (int j = 0; j < list.size(); ++j) {
+ if (list.get(j).getDataVersion() > version) {
+ list.add(j, converter);
+ break;
+ }
+ }
+ } else {
+ list.add(converter);
+ }
+ }
+
+ private void registerInspectors() {
+ registerEntityItemList("EntityHorseDonkey", "SaddleItem", "Items");
+ registerEntityItemList("EntityHorseMule", "Items");
+ registerEntityItemList("EntityMinecartChest", "Items");
+ registerEntityItemList("EntityMinecartHopper", "Items");
+ registerEntityItemList("EntityVillager", "Inventory");
+ registerEntityItemListEquipment("EntityArmorStand");
+ registerEntityItemListEquipment("EntityBat");
+ registerEntityItemListEquipment("EntityBlaze");
+ registerEntityItemListEquipment("EntityCaveSpider");
+ registerEntityItemListEquipment("EntityChicken");
+ registerEntityItemListEquipment("EntityCow");
+ registerEntityItemListEquipment("EntityCreeper");
+ registerEntityItemListEquipment("EntityEnderDragon");
+ registerEntityItemListEquipment("EntityEnderman");
+ registerEntityItemListEquipment("EntityEndermite");
+ registerEntityItemListEquipment("EntityEvoker");
+ registerEntityItemListEquipment("EntityGhast");
+ registerEntityItemListEquipment("EntityGiantZombie");
+ registerEntityItemListEquipment("EntityGuardian");
+ registerEntityItemListEquipment("EntityGuardianElder");
+ registerEntityItemListEquipment("EntityHorse");
+ registerEntityItemListEquipment("EntityHorseDonkey");
+ registerEntityItemListEquipment("EntityHorseMule");
+ registerEntityItemListEquipment("EntityHorseSkeleton");
+ registerEntityItemListEquipment("EntityHorseZombie");
+ registerEntityItemListEquipment("EntityIronGolem");
+ registerEntityItemListEquipment("EntityMagmaCube");
+ registerEntityItemListEquipment("EntityMushroomCow");
+ registerEntityItemListEquipment("EntityOcelot");
+ registerEntityItemListEquipment("EntityPig");
+ registerEntityItemListEquipment("EntityPigZombie");
+ registerEntityItemListEquipment("EntityRabbit");
+ registerEntityItemListEquipment("EntitySheep");
+ registerEntityItemListEquipment("EntityShulker");
+ registerEntityItemListEquipment("EntitySilverfish");
+ registerEntityItemListEquipment("EntitySkeleton");
+ registerEntityItemListEquipment("EntitySkeletonStray");
+ registerEntityItemListEquipment("EntitySkeletonWither");
+ registerEntityItemListEquipment("EntitySlime");
+ registerEntityItemListEquipment("EntitySnowman");
+ registerEntityItemListEquipment("EntitySpider");
+ registerEntityItemListEquipment("EntitySquid");
+ registerEntityItemListEquipment("EntityVex");
+ registerEntityItemListEquipment("EntityVillager");
+ registerEntityItemListEquipment("EntityVindicator");
+ registerEntityItemListEquipment("EntityWitch");
+ registerEntityItemListEquipment("EntityWither");
+ registerEntityItemListEquipment("EntityWolf");
+ registerEntityItemListEquipment("EntityZombie");
+ registerEntityItemListEquipment("EntityZombieHusk");
+ registerEntityItemListEquipment("EntityZombieVillager");
+ registerEntityItemSingle("EntityFireworks", "FireworksItem");
+ registerEntityItemSingle("EntityHorse", "ArmorItem");
+ registerEntityItemSingle("EntityHorse", "SaddleItem");
+ registerEntityItemSingle("EntityHorseMule", "SaddleItem");
+ registerEntityItemSingle("EntityHorseSkeleton", "SaddleItem");
+ registerEntityItemSingle("EntityHorseZombie", "SaddleItem");
+ registerEntityItemSingle("EntityItem", "Item");
+ registerEntityItemSingle("EntityItemFrame", "Item");
+ registerEntityItemSingle("EntityPotion", "Potion");
+
+ registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItem("TileEntityRecordPlayer", "RecordItem"));
+ registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityBrewingStand", "Items"));
+ registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityChest", "Items"));
+ registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityDispenser", "Items"));
+ registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityDropper", "Items"));
+ registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityFurnace", "Items"));
+ registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityHopper", "Items"));
+ registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityShulkerBox", "Items"));
+ registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorMobSpawnerMobs());
+ registerInspector(LegacyType.CHUNK, new DataInspectorChunks());
+ registerInspector(LegacyType.ENTITY, new DataInspectorCommandBlock());
+ registerInspector(LegacyType.ENTITY, new DataInspectorEntityPassengers());
+ registerInspector(LegacyType.ENTITY, new DataInspectorMobSpawnerMinecart());
+ registerInspector(LegacyType.ENTITY, new DataInspectorVillagers());
+ registerInspector(LegacyType.ITEM_INSTANCE, new DataInspectorBlockEntity());
+ registerInspector(LegacyType.ITEM_INSTANCE, new DataInspectorEntity());
+ registerInspector(LegacyType.LEVEL, new DataInspectorLevelPlayer());
+ registerInspector(LegacyType.PLAYER, new DataInspectorPlayer());
+ registerInspector(LegacyType.PLAYER, new DataInspectorPlayerVehicle());
+ registerInspector(LegacyType.STRUCTURE, new DataInspectorStructure());
+ }
+
+ private void registerConverters() {
+ registerConverter(LegacyType.ENTITY, new DataConverterEquipment());
+ registerConverter(LegacyType.BLOCK_ENTITY, new DataConverterSignText());
+ registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterMaterialId());
+ registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterPotionId());
+ registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterSpawnEgg());
+ registerConverter(LegacyType.ENTITY, new DataConverterMinecart());
+ registerConverter(LegacyType.BLOCK_ENTITY, new DataConverterMobSpawner());
+ registerConverter(LegacyType.ENTITY, new DataConverterUUID());
+ registerConverter(LegacyType.ENTITY, new DataConverterHealth());
+ registerConverter(LegacyType.ENTITY, new DataConverterSaddle());
+ registerConverter(LegacyType.ENTITY, new DataConverterHanging());
+ registerConverter(LegacyType.ENTITY, new DataConverterDropChances());
+ registerConverter(LegacyType.ENTITY, new DataConverterRiding());
+ registerConverter(LegacyType.ENTITY, new DataConverterArmorStand());
+ registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterBook());
+ registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterCookedFish());
+ registerConverter(LegacyType.ENTITY, new DataConverterZombie());
+ registerConverter(LegacyType.OPTIONS, new DataConverterVBO());
+ registerConverter(LegacyType.ENTITY, new DataConverterGuardian());
+ registerConverter(LegacyType.ENTITY, new DataConverterSkeleton());
+ registerConverter(LegacyType.ENTITY, new DataConverterZombieType());
+ registerConverter(LegacyType.ENTITY, new DataConverterHorse());
+ registerConverter(LegacyType.BLOCK_ENTITY, new DataConverterTileEntity());
+ registerConverter(LegacyType.ENTITY, new DataConverterEntity());
+ registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterBanner());
+ registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterPotionWater());
+ registerConverter(LegacyType.ENTITY, new DataConverterShulker());
+ registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterShulkerBoxItem());
+ registerConverter(LegacyType.BLOCK_ENTITY, new DataConverterShulkerBoxBlock());
+ registerConverter(LegacyType.OPTIONS, new DataConverterLang());
+ registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterTotem());
+ registerConverter(LegacyType.CHUNK, new DataConverterBedBlock());
+ registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterBedItem());
+ }
+
+ private void registerEntityItemList(String type, String... keys) {
+ registerInspector(LegacyType.ENTITY, new DataInspectorItemList(type, keys));
+ }
+
+ private void registerEntityItemSingle(String type, String key) {
+ registerInspector(LegacyType.ENTITY, new DataInspectorItem(type, key));
+ }
+
+ private void registerEntityItemListEquipment(String type) {
+ registerEntityItemList(type, "ArmorItems", "HandItems");
+ }
+
+ private static final Map OLD_ID_TO_KEY_MAP = new HashMap<>();
+
+ static {
+ final Map map = OLD_ID_TO_KEY_MAP;
+ map.put("EntityItem", new ResourceLocation("item"));
+ map.put("EntityExperienceOrb", new ResourceLocation("xp_orb"));
+ map.put("EntityAreaEffectCloud", new ResourceLocation("area_effect_cloud"));
+ map.put("EntityGuardianElder", new ResourceLocation("elder_guardian"));
+ map.put("EntitySkeletonWither", new ResourceLocation("wither_skeleton"));
+ map.put("EntitySkeletonStray", new ResourceLocation("stray"));
+ map.put("EntityEgg", new ResourceLocation("egg"));
+ map.put("EntityLeash", new ResourceLocation("leash_knot"));
+ map.put("EntityPainting", new ResourceLocation("painting"));
+ map.put("EntityTippedArrow", new ResourceLocation("arrow"));
+ map.put("EntitySnowball", new ResourceLocation("snowball"));
+ map.put("EntityLargeFireball", new ResourceLocation("fireball"));
+ map.put("EntitySmallFireball", new ResourceLocation("small_fireball"));
+ map.put("EntityEnderPearl", new ResourceLocation("ender_pearl"));
+ map.put("EntityEnderSignal", new ResourceLocation("eye_of_ender_signal"));
+ map.put("EntityPotion", new ResourceLocation("potion"));
+ map.put("EntityThrownExpBottle", new ResourceLocation("xp_bottle"));
+ map.put("EntityItemFrame", new ResourceLocation("item_frame"));
+ map.put("EntityWitherSkull", new ResourceLocation("wither_skull"));
+ map.put("EntityTNTPrimed", new ResourceLocation("tnt"));
+ map.put("EntityFallingBlock", new ResourceLocation("falling_block"));
+ map.put("EntityFireworks", new ResourceLocation("fireworks_rocket"));
+ map.put("EntityZombieHusk", new ResourceLocation("husk"));
+ map.put("EntitySpectralArrow", new ResourceLocation("spectral_arrow"));
+ map.put("EntityShulkerBullet", new ResourceLocation("shulker_bullet"));
+ map.put("EntityDragonFireball", new ResourceLocation("dragon_fireball"));
+ map.put("EntityZombieVillager", new ResourceLocation("zombie_villager"));
+ map.put("EntityHorseSkeleton", new ResourceLocation("skeleton_horse"));
+ map.put("EntityHorseZombie", new ResourceLocation("zombie_horse"));
+ map.put("EntityArmorStand", new ResourceLocation("armor_stand"));
+ map.put("EntityHorseDonkey", new ResourceLocation("donkey"));
+ map.put("EntityHorseMule", new ResourceLocation("mule"));
+ map.put("EntityEvokerFangs", new ResourceLocation("evocation_fangs"));
+ map.put("EntityEvoker", new ResourceLocation("evocation_illager"));
+ map.put("EntityVex", new ResourceLocation("vex"));
+ map.put("EntityVindicator", new ResourceLocation("vindication_illager"));
+ map.put("EntityIllagerIllusioner", new ResourceLocation("illusion_illager"));
+ map.put("EntityMinecartCommandBlock", new ResourceLocation("commandblock_minecart"));
+ map.put("EntityBoat", new ResourceLocation("boat"));
+ map.put("EntityMinecartRideable", new ResourceLocation("minecart"));
+ map.put("EntityMinecartChest", new ResourceLocation("chest_minecart"));
+ map.put("EntityMinecartFurnace", new ResourceLocation("furnace_minecart"));
+ map.put("EntityMinecartTNT", new ResourceLocation("tnt_minecart"));
+ map.put("EntityMinecartHopper", new ResourceLocation("hopper_minecart"));
+ map.put("EntityMinecartMobSpawner", new ResourceLocation("spawner_minecart"));
+ map.put("EntityCreeper", new ResourceLocation("creeper"));
+ map.put("EntitySkeleton", new ResourceLocation("skeleton"));
+ map.put("EntitySpider", new ResourceLocation("spider"));
+ map.put("EntityGiantZombie", new ResourceLocation("giant"));
+ map.put("EntityZombie", new ResourceLocation("zombie"));
+ map.put("EntitySlime", new ResourceLocation("slime"));
+ map.put("EntityGhast", new ResourceLocation("ghast"));
+ map.put("EntityPigZombie", new ResourceLocation("zombie_pigman"));
+ map.put("EntityEnderman", new ResourceLocation("enderman"));
+ map.put("EntityCaveSpider", new ResourceLocation("cave_spider"));
+ map.put("EntitySilverfish", new ResourceLocation("silverfish"));
+ map.put("EntityBlaze", new ResourceLocation("blaze"));
+ map.put("EntityMagmaCube", new ResourceLocation("magma_cube"));
+ map.put("EntityEnderDragon", new ResourceLocation("ender_dragon"));
+ map.put("EntityWither", new ResourceLocation("wither"));
+ map.put("EntityBat", new ResourceLocation("bat"));
+ map.put("EntityWitch", new ResourceLocation("witch"));
+ map.put("EntityEndermite", new ResourceLocation("endermite"));
+ map.put("EntityGuardian", new ResourceLocation("guardian"));
+ map.put("EntityShulker", new ResourceLocation("shulker"));
+ map.put("EntityPig", new ResourceLocation("pig"));
+ map.put("EntitySheep", new ResourceLocation("sheep"));
+ map.put("EntityCow", new ResourceLocation("cow"));
+ map.put("EntityChicken", new ResourceLocation("chicken"));
+ map.put("EntitySquid", new ResourceLocation("squid"));
+ map.put("EntityWolf", new ResourceLocation("wolf"));
+ map.put("EntityMushroomCow", new ResourceLocation("mooshroom"));
+ map.put("EntitySnowman", new ResourceLocation("snowman"));
+ map.put("EntityOcelot", new ResourceLocation("ocelot"));
+ map.put("EntityIronGolem", new ResourceLocation("villager_golem"));
+ map.put("EntityHorse", new ResourceLocation("horse"));
+ map.put("EntityRabbit", new ResourceLocation("rabbit"));
+ map.put("EntityPolarBear", new ResourceLocation("polar_bear"));
+ map.put("EntityLlama", new ResourceLocation("llama"));
+ map.put("EntityLlamaSpit", new ResourceLocation("llama_spit"));
+ map.put("EntityParrot", new ResourceLocation("parrot"));
+ map.put("EntityVillager", new ResourceLocation("villager"));
+ map.put("EntityEnderCrystal", new ResourceLocation("ender_crystal"));
+ map.put("TileEntityFurnace", new ResourceLocation("furnace"));
+ map.put("TileEntityChest", new ResourceLocation("chest"));
+ map.put("TileEntityEnderChest", new ResourceLocation("ender_chest"));
+ map.put("TileEntityRecordPlayer", new ResourceLocation("jukebox"));
+ map.put("TileEntityDispenser", new ResourceLocation("dispenser"));
+ map.put("TileEntityDropper", new ResourceLocation("dropper"));
+ map.put("TileEntitySign", new ResourceLocation("sign"));
+ map.put("TileEntityMobSpawner", new ResourceLocation("mob_spawner"));
+ map.put("TileEntityNote", new ResourceLocation("noteblock"));
+ map.put("TileEntityPiston", new ResourceLocation("piston"));
+ map.put("TileEntityBrewingStand", new ResourceLocation("brewing_stand"));
+ map.put("TileEntityEnchantTable", new ResourceLocation("enchanting_table"));
+ map.put("TileEntityEnderPortal", new ResourceLocation("end_portal"));
+ map.put("TileEntityBeacon", new ResourceLocation("beacon"));
+ map.put("TileEntitySkull", new ResourceLocation("skull"));
+ map.put("TileEntityLightDetector", new ResourceLocation("daylight_detector"));
+ map.put("TileEntityHopper", new ResourceLocation("hopper"));
+ map.put("TileEntityComparator", new ResourceLocation("comparator"));
+ map.put("TileEntityFlowerPot", new ResourceLocation("flower_pot"));
+ map.put("TileEntityBanner", new ResourceLocation("banner"));
+ map.put("TileEntityStructure", new ResourceLocation("structure_block"));
+ map.put("TileEntityEndGateway", new ResourceLocation("end_gateway"));
+ map.put("TileEntityCommand", new ResourceLocation("command_block"));
+ map.put("TileEntityShulkerBox", new ResourceLocation("shulker_box"));
+ map.put("TileEntityBed", new ResourceLocation("bed"));
+ }
+
+ private static ResourceLocation getKey(String type) {
+ final ResourceLocation key = OLD_ID_TO_KEY_MAP.get(type);
+ if (key == null) {
+ throw new IllegalArgumentException("Unknown mapping for " + type);
+ }
+ return key;
+ }
+
+ private static void convertCompound(LegacyType type, CompoundTag cmp, String key, int sourceVer, int targetVer) {
+ cmp.put(key, convert(type, cmp.getCompound(key), sourceVer, targetVer));
+ }
+
+ private static void convertItem(CompoundTag nbttagcompound, String key, int sourceVer, int targetVer) {
+ if (nbttagcompound.contains(key, 10)) {
+ convertCompound(LegacyType.ITEM_INSTANCE, nbttagcompound, key, sourceVer, targetVer);
+ }
+ }
+
+ private static void convertItems(CompoundTag nbttagcompound, String key, int sourceVer, int targetVer) {
+ if (nbttagcompound.contains(key, 9)) {
+ ListTag nbttaglist = nbttagcompound.getList(key, 10);
+
+ for (int j = 0; j < nbttaglist.size(); ++j) {
+ nbttaglist.set(j, convert(LegacyType.ITEM_INSTANCE, nbttaglist.getCompound(j), sourceVer, targetVer));
+ }
+ }
+
+ }
+
+ private static class DataConverterEquipment implements DataConverter {
+
+ DataConverterEquipment() {
+ }
+
+ public int getDataVersion() {
+ return 100;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ ListTag nbttaglist = cmp.getList("Equipment", 10);
+ ListTag nbttaglist1;
+
+ if (!nbttaglist.isEmpty() && !cmp.contains("HandItems", 10)) {
+ nbttaglist1 = new ListTag();
+ nbttaglist1.add(nbttaglist.get(0));
+ nbttaglist1.add(new CompoundTag());
+ cmp.put("HandItems", nbttaglist1);
+ }
+
+ if (nbttaglist.size() > 1 && !cmp.contains("ArmorItem", 10)) {
+ nbttaglist1 = new ListTag();
+ nbttaglist1.add(nbttaglist.get(1));
+ nbttaglist1.add(nbttaglist.get(2));
+ nbttaglist1.add(nbttaglist.get(3));
+ nbttaglist1.add(nbttaglist.get(4));
+ cmp.put("ArmorItems", nbttaglist1);
+ }
+
+ cmp.remove("Equipment");
+ if (cmp.contains("DropChances", 9)) {
+ nbttaglist1 = cmp.getList("DropChances", 5);
+ ListTag nbttaglist2;
+
+ if (!cmp.contains("HandDropChances", 10)) {
+ nbttaglist2 = new ListTag();
+ nbttaglist2.add(FloatTag.valueOf(nbttaglist1.getFloat(0)));
+ nbttaglist2.add(FloatTag.valueOf(0.0F));
+ cmp.put("HandDropChances", nbttaglist2);
+ }
+
+ if (!cmp.contains("ArmorDropChances", 10)) {
+ nbttaglist2 = new ListTag();
+ nbttaglist2.add(FloatTag.valueOf(nbttaglist1.getFloat(1)));
+ nbttaglist2.add(FloatTag.valueOf(nbttaglist1.getFloat(2)));
+ nbttaglist2.add(FloatTag.valueOf(nbttaglist1.getFloat(3)));
+ nbttaglist2.add(FloatTag.valueOf(nbttaglist1.getFloat(4)));
+ cmp.put("ArmorDropChances", nbttaglist2);
+ }
+
+ cmp.remove("DropChances");
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataInspectorBlockEntity implements DataInspector {
+
+ private static final Map b = Maps.newHashMap();
+ private static final Map c = Maps.newHashMap();
+
+ DataInspectorBlockEntity() {
+ }
+
+ @Nullable
+ private static String convertEntityId(int i, String s) {
+ String key = new ResourceLocation(s).toString();
+ if (i < 515 && DataInspectorBlockEntity.b.containsKey(key)) {
+ return DataInspectorBlockEntity.b.get(key);
+ } else {
+ return DataInspectorBlockEntity.c.get(key);
+ }
+ }
+
+ public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
+ if (!cmp.contains("tag", 10)) {
+ return cmp;
+ } else {
+ CompoundTag nbttagcompound1 = cmp.getCompound("tag");
+
+ if (nbttagcompound1.contains("BlockEntityTag", 10)) {
+ CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
+ String s = cmp.getString("id");
+ String s1 = convertEntityId(sourceVer, s);
+ boolean flag;
+
+ if (s1 == null) {
+ // CraftBukkit - Remove unnecessary warning (occurs when deserializing a Shulker Box item)
+ // DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", s);
+ flag = false;
+ } else {
+ flag = !nbttagcompound2.contains("id");
+ nbttagcompound2.putString("id", s1);
+ }
+
+ convert(LegacyType.BLOCK_ENTITY, nbttagcompound2, sourceVer, targetVer);
+ if (flag) {
+ nbttagcompound2.remove("id");
+ }
+ }
+
+ return cmp;
+ }
+ }
+
+ static {
+ Map map = DataInspectorBlockEntity.b;
+
+ map.put("minecraft:furnace", "Furnace");
+ map.put("minecraft:lit_furnace", "Furnace");
+ map.put("minecraft:chest", "Chest");
+ map.put("minecraft:trapped_chest", "Chest");
+ map.put("minecraft:ender_chest", "EnderChest");
+ map.put("minecraft:jukebox", "RecordPlayer");
+ map.put("minecraft:dispenser", "Trap");
+ map.put("minecraft:dropper", "Dropper");
+ map.put("minecraft:sign", "Sign");
+ map.put("minecraft:mob_spawner", "MobSpawner");
+ map.put("minecraft:noteblock", "Music");
+ map.put("minecraft:brewing_stand", "Cauldron");
+ map.put("minecraft:enhanting_table", "EnchantTable");
+ map.put("minecraft:command_block", "CommandBlock");
+ map.put("minecraft:beacon", "Beacon");
+ map.put("minecraft:skull", "Skull");
+ map.put("minecraft:daylight_detector", "DLDetector");
+ map.put("minecraft:hopper", "Hopper");
+ map.put("minecraft:banner", "Banner");
+ map.put("minecraft:flower_pot", "FlowerPot");
+ map.put("minecraft:repeating_command_block", "CommandBlock");
+ map.put("minecraft:chain_command_block", "CommandBlock");
+ map.put("minecraft:standing_sign", "Sign");
+ map.put("minecraft:wall_sign", "Sign");
+ map.put("minecraft:piston_head", "Piston");
+ map.put("minecraft:daylight_detector_inverted", "DLDetector");
+ map.put("minecraft:unpowered_comparator", "Comparator");
+ map.put("minecraft:powered_comparator", "Comparator");
+ map.put("minecraft:wall_banner", "Banner");
+ map.put("minecraft:standing_banner", "Banner");
+ map.put("minecraft:structure_block", "Structure");
+ map.put("minecraft:end_portal", "Airportal");
+ map.put("minecraft:end_gateway", "EndGateway");
+ map.put("minecraft:shield", "Shield");
+ map = DataInspectorBlockEntity.c;
+ map.put("minecraft:furnace", "minecraft:furnace");
+ map.put("minecraft:lit_furnace", "minecraft:furnace");
+ map.put("minecraft:chest", "minecraft:chest");
+ map.put("minecraft:trapped_chest", "minecraft:chest");
+ map.put("minecraft:ender_chest", "minecraft:enderchest");
+ map.put("minecraft:jukebox", "minecraft:jukebox");
+ map.put("minecraft:dispenser", "minecraft:dispenser");
+ map.put("minecraft:dropper", "minecraft:dropper");
+ map.put("minecraft:sign", "minecraft:sign");
+ map.put("minecraft:mob_spawner", "minecraft:mob_spawner");
+ map.put("minecraft:noteblock", "minecraft:noteblock");
+ map.put("minecraft:brewing_stand", "minecraft:brewing_stand");
+ map.put("minecraft:enhanting_table", "minecraft:enchanting_table");
+ map.put("minecraft:command_block", "minecraft:command_block");
+ map.put("minecraft:beacon", "minecraft:beacon");
+ map.put("minecraft:skull", "minecraft:skull");
+ map.put("minecraft:daylight_detector", "minecraft:daylight_detector");
+ map.put("minecraft:hopper", "minecraft:hopper");
+ map.put("minecraft:banner", "minecraft:banner");
+ map.put("minecraft:flower_pot", "minecraft:flower_pot");
+ map.put("minecraft:repeating_command_block", "minecraft:command_block");
+ map.put("minecraft:chain_command_block", "minecraft:command_block");
+ map.put("minecraft:shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:white_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:orange_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:magenta_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:light_blue_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:yellow_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:lime_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:pink_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:gray_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:silver_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:cyan_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:purple_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:blue_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:brown_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:green_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:red_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:black_shulker_box", "minecraft:shulker_box");
+ map.put("minecraft:bed", "minecraft:bed");
+ map.put("minecraft:standing_sign", "minecraft:sign");
+ map.put("minecraft:wall_sign", "minecraft:sign");
+ map.put("minecraft:piston_head", "minecraft:piston");
+ map.put("minecraft:daylight_detector_inverted", "minecraft:daylight_detector");
+ map.put("minecraft:unpowered_comparator", "minecraft:comparator");
+ map.put("minecraft:powered_comparator", "minecraft:comparator");
+ map.put("minecraft:wall_banner", "minecraft:banner");
+ map.put("minecraft:standing_banner", "minecraft:banner");
+ map.put("minecraft:structure_block", "minecraft:structure_block");
+ map.put("minecraft:end_portal", "minecraft:end_portal");
+ map.put("minecraft:end_gateway", "minecraft:end_gateway");
+ map.put("minecraft:shield", "minecraft:shield");
+ }
+ }
+
+ private static class DataInspectorEntity implements DataInspector {
+
+ DataInspectorEntity() {
+ }
+
+ public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
+ CompoundTag nbttagcompound1 = cmp.getCompound("tag");
+
+ if (nbttagcompound1.contains("EntityTag", 10)) {
+ CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("EntityTag");
+ String s = cmp.getString("id");
+ String s1;
+
+ if ("minecraft:armor_stand".equals(s)) {
+ s1 = sourceVer < 515 ? "ArmorStand" : "minecraft:armor_stand";
+ } else {
+ if (!"minecraft:spawn_egg".equals(s)) {
+ return cmp;
+ }
+
+ s1 = nbttagcompound2.getString("id");
+ }
+
+ boolean flag;
+
+ flag = !nbttagcompound2.contains("id", 8);
+ nbttagcompound2.putString("id", s1);
+
+ convert(LegacyType.ENTITY, nbttagcompound2, sourceVer, targetVer);
+ if (flag) {
+ nbttagcompound2.remove("id");
+ }
+ }
+
+ return cmp;
+ }
+ }
+
+
+ private abstract static class DataInspectorTagged implements DataInspector {
+
+ private final ResourceLocation key;
+
+ DataInspectorTagged(String type) {
+ this.key = getKey(type);
+ }
+
+ public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
+ if (this.key.equals(new ResourceLocation(cmp.getString("id")))) {
+ cmp = this.inspectChecked(cmp, sourceVer, targetVer);
+ }
+
+ return cmp;
+ }
+
+ abstract CompoundTag inspectChecked(CompoundTag nbttagcompound, int sourceVer, int targetVer);
+ }
+
+ private static class DataInspectorItemList extends DataInspectorTagged {
+
+ private final String[] keys;
+
+ DataInspectorItemList(String oclass, String... astring) {
+ super(oclass);
+ this.keys = astring;
+ }
+
+ CompoundTag inspectChecked(CompoundTag nbttagcompound, int sourceVer, int targetVer) {
+ for (String s : this.keys) {
+ PaperweightDataConverters.convertItems(nbttagcompound, s, sourceVer, targetVer);
+ }
+
+ return nbttagcompound;
+ }
+ }
+
+ private static class DataInspectorItem extends DataInspectorTagged {
+
+ private final String[] keys;
+
+ DataInspectorItem(String oclass, String... astring) {
+ super(oclass);
+ this.keys = astring;
+ }
+
+ CompoundTag inspectChecked(CompoundTag nbttagcompound, int sourceVer, int targetVer) {
+ for (String key : this.keys) {
+ PaperweightDataConverters.convertItem(nbttagcompound, key, sourceVer, targetVer);
+ }
+
+ return nbttagcompound;
+ }
+ }
+
+ private static class DataConverterMaterialId implements DataConverter {
+
+ private static final String[] materials = new String[2268];
+
+ DataConverterMaterialId() {
+ }
+
+ public int getDataVersion() {
+ return 102;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if (cmp.contains("id", 99)) {
+ short short0 = cmp.getShort("id");
+
+ if (short0 > 0 && short0 < materials.length && materials[short0] != null) {
+ cmp.putString("id", materials[short0]);
+ }
+ }
+
+ return cmp;
+ }
+
+ static {
+ materials[1] = "minecraft:stone";
+ materials[2] = "minecraft:grass";
+ materials[3] = "minecraft:dirt";
+ materials[4] = "minecraft:cobblestone";
+ materials[5] = "minecraft:planks";
+ materials[6] = "minecraft:sapling";
+ materials[7] = "minecraft:bedrock";
+ materials[8] = "minecraft:flowing_water";
+ materials[9] = "minecraft:water";
+ materials[10] = "minecraft:flowing_lava";
+ materials[11] = "minecraft:lava";
+ materials[12] = "minecraft:sand";
+ materials[13] = "minecraft:gravel";
+ materials[14] = "minecraft:gold_ore";
+ materials[15] = "minecraft:iron_ore";
+ materials[16] = "minecraft:coal_ore";
+ materials[17] = "minecraft:log";
+ materials[18] = "minecraft:leaves";
+ materials[19] = "minecraft:sponge";
+ materials[20] = "minecraft:glass";
+ materials[21] = "minecraft:lapis_ore";
+ materials[22] = "minecraft:lapis_block";
+ materials[23] = "minecraft:dispenser";
+ materials[24] = "minecraft:sandstone";
+ materials[25] = "minecraft:noteblock";
+ materials[27] = "minecraft:golden_rail";
+ materials[28] = "minecraft:detector_rail";
+ materials[29] = "minecraft:sticky_piston";
+ materials[30] = "minecraft:web";
+ materials[31] = "minecraft:tallgrass";
+ materials[32] = "minecraft:deadbush";
+ materials[33] = "minecraft:piston";
+ materials[35] = "minecraft:wool";
+ materials[37] = "minecraft:yellow_flower";
+ materials[38] = "minecraft:red_flower";
+ materials[39] = "minecraft:brown_mushroom";
+ materials[40] = "minecraft:red_mushroom";
+ materials[41] = "minecraft:gold_block";
+ materials[42] = "minecraft:iron_block";
+ materials[43] = "minecraft:double_stone_slab";
+ materials[44] = "minecraft:stone_slab";
+ materials[45] = "minecraft:brick_block";
+ materials[46] = "minecraft:tnt";
+ materials[47] = "minecraft:bookshelf";
+ materials[48] = "minecraft:mossy_cobblestone";
+ materials[49] = "minecraft:obsidian";
+ materials[50] = "minecraft:torch";
+ materials[51] = "minecraft:fire";
+ materials[52] = "minecraft:mob_spawner";
+ materials[53] = "minecraft:oak_stairs";
+ materials[54] = "minecraft:chest";
+ materials[56] = "minecraft:diamond_ore";
+ materials[57] = "minecraft:diamond_block";
+ materials[58] = "minecraft:crafting_table";
+ materials[60] = "minecraft:farmland";
+ materials[61] = "minecraft:furnace";
+ materials[62] = "minecraft:lit_furnace";
+ materials[65] = "minecraft:ladder";
+ materials[66] = "minecraft:rail";
+ materials[67] = "minecraft:stone_stairs";
+ materials[69] = "minecraft:lever";
+ materials[70] = "minecraft:stone_pressure_plate";
+ materials[72] = "minecraft:wooden_pressure_plate";
+ materials[73] = "minecraft:redstone_ore";
+ materials[76] = "minecraft:redstone_torch";
+ materials[77] = "minecraft:stone_button";
+ materials[78] = "minecraft:snow_layer";
+ materials[79] = "minecraft:ice";
+ materials[80] = "minecraft:snow";
+ materials[81] = "minecraft:cactus";
+ materials[82] = "minecraft:clay";
+ materials[84] = "minecraft:jukebox";
+ materials[85] = "minecraft:fence";
+ materials[86] = "minecraft:pumpkin";
+ materials[87] = "minecraft:netherrack";
+ materials[88] = "minecraft:soul_sand";
+ materials[89] = "minecraft:glowstone";
+ materials[90] = "minecraft:portal";
+ materials[91] = "minecraft:lit_pumpkin";
+ materials[95] = "minecraft:stained_glass";
+ materials[96] = "minecraft:trapdoor";
+ materials[97] = "minecraft:monster_egg";
+ materials[98] = "minecraft:stonebrick";
+ materials[99] = "minecraft:brown_mushroom_block";
+ materials[100] = "minecraft:red_mushroom_block";
+ materials[101] = "minecraft:iron_bars";
+ materials[102] = "minecraft:glass_pane";
+ materials[103] = "minecraft:melon_block";
+ materials[106] = "minecraft:vine";
+ materials[107] = "minecraft:fence_gate";
+ materials[108] = "minecraft:brick_stairs";
+ materials[109] = "minecraft:stone_brick_stairs";
+ materials[110] = "minecraft:mycelium";
+ materials[111] = "minecraft:waterlily";
+ materials[112] = "minecraft:nether_brick";
+ materials[113] = "minecraft:nether_brick_fence";
+ materials[114] = "minecraft:nether_brick_stairs";
+ materials[116] = "minecraft:enchanting_table";
+ materials[119] = "minecraft:end_portal";
+ materials[120] = "minecraft:end_portal_frame";
+ materials[121] = "minecraft:end_stone";
+ materials[122] = "minecraft:dragon_egg";
+ materials[123] = "minecraft:redstone_lamp";
+ materials[125] = "minecraft:double_wooden_slab";
+ materials[126] = "minecraft:wooden_slab";
+ materials[127] = "minecraft:cocoa";
+ materials[128] = "minecraft:sandstone_stairs";
+ materials[129] = "minecraft:emerald_ore";
+ materials[130] = "minecraft:ender_chest";
+ materials[131] = "minecraft:tripwire_hook";
+ materials[133] = "minecraft:emerald_block";
+ materials[134] = "minecraft:spruce_stairs";
+ materials[135] = "minecraft:birch_stairs";
+ materials[136] = "minecraft:jungle_stairs";
+ materials[137] = "minecraft:command_block";
+ materials[138] = "minecraft:beacon";
+ materials[139] = "minecraft:cobblestone_wall";
+ materials[141] = "minecraft:carrots";
+ materials[142] = "minecraft:potatoes";
+ materials[143] = "minecraft:wooden_button";
+ materials[145] = "minecraft:anvil";
+ materials[146] = "minecraft:trapped_chest";
+ materials[147] = "minecraft:light_weighted_pressure_plate";
+ materials[148] = "minecraft:heavy_weighted_pressure_plate";
+ materials[151] = "minecraft:daylight_detector";
+ materials[152] = "minecraft:redstone_block";
+ materials[153] = "minecraft:quartz_ore";
+ materials[154] = "minecraft:hopper";
+ materials[155] = "minecraft:quartz_block";
+ materials[156] = "minecraft:quartz_stairs";
+ materials[157] = "minecraft:activator_rail";
+ materials[158] = "minecraft:dropper";
+ materials[159] = "minecraft:stained_hardened_clay";
+ materials[160] = "minecraft:stained_glass_pane";
+ materials[161] = "minecraft:leaves2";
+ materials[162] = "minecraft:log2";
+ materials[163] = "minecraft:acacia_stairs";
+ materials[164] = "minecraft:dark_oak_stairs";
+ materials[170] = "minecraft:hay_block";
+ materials[171] = "minecraft:carpet";
+ materials[172] = "minecraft:hardened_clay";
+ materials[173] = "minecraft:coal_block";
+ materials[174] = "minecraft:packed_ice";
+ materials[175] = "minecraft:double_plant";
+ materials[256] = "minecraft:iron_shovel";
+ materials[257] = "minecraft:iron_pickaxe";
+ materials[258] = "minecraft:iron_axe";
+ materials[259] = "minecraft:flint_and_steel";
+ materials[260] = "minecraft:apple";
+ materials[261] = "minecraft:bow";
+ materials[262] = "minecraft:arrow";
+ materials[263] = "minecraft:coal";
+ materials[264] = "minecraft:diamond";
+ materials[265] = "minecraft:iron_ingot";
+ materials[266] = "minecraft:gold_ingot";
+ materials[267] = "minecraft:iron_sword";
+ materials[268] = "minecraft:wooden_sword";
+ materials[269] = "minecraft:wooden_shovel";
+ materials[270] = "minecraft:wooden_pickaxe";
+ materials[271] = "minecraft:wooden_axe";
+ materials[272] = "minecraft:stone_sword";
+ materials[273] = "minecraft:stone_shovel";
+ materials[274] = "minecraft:stone_pickaxe";
+ materials[275] = "minecraft:stone_axe";
+ materials[276] = "minecraft:diamond_sword";
+ materials[277] = "minecraft:diamond_shovel";
+ materials[278] = "minecraft:diamond_pickaxe";
+ materials[279] = "minecraft:diamond_axe";
+ materials[280] = "minecraft:stick";
+ materials[281] = "minecraft:bowl";
+ materials[282] = "minecraft:mushroom_stew";
+ materials[283] = "minecraft:golden_sword";
+ materials[284] = "minecraft:golden_shovel";
+ materials[285] = "minecraft:golden_pickaxe";
+ materials[286] = "minecraft:golden_axe";
+ materials[287] = "minecraft:string";
+ materials[288] = "minecraft:feather";
+ materials[289] = "minecraft:gunpowder";
+ materials[290] = "minecraft:wooden_hoe";
+ materials[291] = "minecraft:stone_hoe";
+ materials[292] = "minecraft:iron_hoe";
+ materials[293] = "minecraft:diamond_hoe";
+ materials[294] = "minecraft:golden_hoe";
+ materials[295] = "minecraft:wheat_seeds";
+ materials[296] = "minecraft:wheat";
+ materials[297] = "minecraft:bread";
+ materials[298] = "minecraft:leather_helmet";
+ materials[299] = "minecraft:leather_chestplate";
+ materials[300] = "minecraft:leather_leggings";
+ materials[301] = "minecraft:leather_boots";
+ materials[302] = "minecraft:chainmail_helmet";
+ materials[303] = "minecraft:chainmail_chestplate";
+ materials[304] = "minecraft:chainmail_leggings";
+ materials[305] = "minecraft:chainmail_boots";
+ materials[306] = "minecraft:iron_helmet";
+ materials[307] = "minecraft:iron_chestplate";
+ materials[308] = "minecraft:iron_leggings";
+ materials[309] = "minecraft:iron_boots";
+ materials[310] = "minecraft:diamond_helmet";
+ materials[311] = "minecraft:diamond_chestplate";
+ materials[312] = "minecraft:diamond_leggings";
+ materials[313] = "minecraft:diamond_boots";
+ materials[314] = "minecraft:golden_helmet";
+ materials[315] = "minecraft:golden_chestplate";
+ materials[316] = "minecraft:golden_leggings";
+ materials[317] = "minecraft:golden_boots";
+ materials[318] = "minecraft:flint";
+ materials[319] = "minecraft:porkchop";
+ materials[320] = "minecraft:cooked_porkchop";
+ materials[321] = "minecraft:painting";
+ materials[322] = "minecraft:golden_apple";
+ materials[323] = "minecraft:sign";
+ materials[324] = "minecraft:wooden_door";
+ materials[325] = "minecraft:bucket";
+ materials[326] = "minecraft:water_bucket";
+ materials[327] = "minecraft:lava_bucket";
+ materials[328] = "minecraft:minecart";
+ materials[329] = "minecraft:saddle";
+ materials[330] = "minecraft:iron_door";
+ materials[331] = "minecraft:redstone";
+ materials[332] = "minecraft:snowball";
+ materials[333] = "minecraft:boat";
+ materials[334] = "minecraft:leather";
+ materials[335] = "minecraft:milk_bucket";
+ materials[336] = "minecraft:brick";
+ materials[337] = "minecraft:clay_ball";
+ materials[338] = "minecraft:reeds";
+ materials[339] = "minecraft:paper";
+ materials[340] = "minecraft:book";
+ materials[341] = "minecraft:slime_ball";
+ materials[342] = "minecraft:chest_minecart";
+ materials[343] = "minecraft:furnace_minecart";
+ materials[344] = "minecraft:egg";
+ materials[345] = "minecraft:compass";
+ materials[346] = "minecraft:fishing_rod";
+ materials[347] = "minecraft:clock";
+ materials[348] = "minecraft:glowstone_dust";
+ materials[349] = "minecraft:fish";
+ materials[350] = "minecraft:cooked_fish"; // Paper - cooked_fished -> cooked_fish
+ materials[351] = "minecraft:dye";
+ materials[352] = "minecraft:bone";
+ materials[353] = "minecraft:sugar";
+ materials[354] = "minecraft:cake";
+ materials[355] = "minecraft:bed";
+ materials[356] = "minecraft:repeater";
+ materials[357] = "minecraft:cookie";
+ materials[358] = "minecraft:filled_map";
+ materials[359] = "minecraft:shears";
+ materials[360] = "minecraft:melon";
+ materials[361] = "minecraft:pumpkin_seeds";
+ materials[362] = "minecraft:melon_seeds";
+ materials[363] = "minecraft:beef";
+ materials[364] = "minecraft:cooked_beef";
+ materials[365] = "minecraft:chicken";
+ materials[366] = "minecraft:cooked_chicken";
+ materials[367] = "minecraft:rotten_flesh";
+ materials[368] = "minecraft:ender_pearl";
+ materials[369] = "minecraft:blaze_rod";
+ materials[370] = "minecraft:ghast_tear";
+ materials[371] = "minecraft:gold_nugget";
+ materials[372] = "minecraft:nether_wart";
+ materials[373] = "minecraft:potion";
+ materials[374] = "minecraft:glass_bottle";
+ materials[375] = "minecraft:spider_eye";
+ materials[376] = "minecraft:fermented_spider_eye";
+ materials[377] = "minecraft:blaze_powder";
+ materials[378] = "minecraft:magma_cream";
+ materials[379] = "minecraft:brewing_stand";
+ materials[380] = "minecraft:cauldron";
+ materials[381] = "minecraft:ender_eye";
+ materials[382] = "minecraft:speckled_melon";
+ materials[383] = "minecraft:spawn_egg";
+ materials[384] = "minecraft:experience_bottle";
+ materials[385] = "minecraft:fire_charge";
+ materials[386] = "minecraft:writable_book";
+ materials[387] = "minecraft:written_book";
+ materials[388] = "minecraft:emerald";
+ materials[389] = "minecraft:item_frame";
+ materials[390] = "minecraft:flower_pot";
+ materials[391] = "minecraft:carrot";
+ materials[392] = "minecraft:potato";
+ materials[393] = "minecraft:baked_potato";
+ materials[394] = "minecraft:poisonous_potato";
+ materials[395] = "minecraft:map";
+ materials[396] = "minecraft:golden_carrot";
+ materials[397] = "minecraft:skull";
+ materials[398] = "minecraft:carrot_on_a_stick";
+ materials[399] = "minecraft:nether_star";
+ materials[400] = "minecraft:pumpkin_pie";
+ materials[401] = "minecraft:fireworks";
+ materials[402] = "minecraft:firework_charge";
+ materials[403] = "minecraft:enchanted_book";
+ materials[404] = "minecraft:comparator";
+ materials[405] = "minecraft:netherbrick";
+ materials[406] = "minecraft:quartz";
+ materials[407] = "minecraft:tnt_minecart";
+ materials[408] = "minecraft:hopper_minecart";
+ materials[417] = "minecraft:iron_horse_armor";
+ materials[418] = "minecraft:golden_horse_armor";
+ materials[419] = "minecraft:diamond_horse_armor";
+ materials[420] = "minecraft:lead";
+ materials[421] = "minecraft:name_tag";
+ materials[422] = "minecraft:command_block_minecart";
+ materials[2256] = "minecraft:record_13";
+ materials[2257] = "minecraft:record_cat";
+ materials[2258] = "minecraft:record_blocks";
+ materials[2259] = "minecraft:record_chirp";
+ materials[2260] = "minecraft:record_far";
+ materials[2261] = "minecraft:record_mall";
+ materials[2262] = "minecraft:record_mellohi";
+ materials[2263] = "minecraft:record_stal";
+ materials[2264] = "minecraft:record_strad";
+ materials[2265] = "minecraft:record_ward";
+ materials[2266] = "minecraft:record_11";
+ materials[2267] = "minecraft:record_wait";
+ // Paper start
+ materials[409] = "minecraft:prismarine_shard";
+ materials[410] = "minecraft:prismarine_crystals";
+ materials[411] = "minecraft:rabbit";
+ materials[412] = "minecraft:cooked_rabbit";
+ materials[413] = "minecraft:rabbit_stew";
+ materials[414] = "minecraft:rabbit_foot";
+ materials[415] = "minecraft:rabbit_hide";
+ materials[416] = "minecraft:armor_stand";
+ materials[423] = "minecraft:mutton";
+ materials[424] = "minecraft:cooked_mutton";
+ materials[425] = "minecraft:banner";
+ materials[426] = "minecraft:end_crystal";
+ materials[427] = "minecraft:spruce_door";
+ materials[428] = "minecraft:birch_door";
+ materials[429] = "minecraft:jungle_door";
+ materials[430] = "minecraft:acacia_door";
+ materials[431] = "minecraft:dark_oak_door";
+ materials[432] = "minecraft:chorus_fruit";
+ materials[433] = "minecraft:chorus_fruit_popped";
+ materials[434] = "minecraft:beetroot";
+ materials[435] = "minecraft:beetroot_seeds";
+ materials[436] = "minecraft:beetroot_soup";
+ materials[437] = "minecraft:dragon_breath";
+ materials[438] = "minecraft:splash_potion";
+ materials[439] = "minecraft:spectral_arrow";
+ materials[440] = "minecraft:tipped_arrow";
+ materials[441] = "minecraft:lingering_potion";
+ materials[442] = "minecraft:shield";
+ materials[443] = "minecraft:elytra";
+ materials[444] = "minecraft:spruce_boat";
+ materials[445] = "minecraft:birch_boat";
+ materials[446] = "minecraft:jungle_boat";
+ materials[447] = "minecraft:acacia_boat";
+ materials[448] = "minecraft:dark_oak_boat";
+ materials[449] = "minecraft:totem_of_undying";
+ materials[450] = "minecraft:shulker_shell";
+ materials[452] = "minecraft:iron_nugget";
+ materials[453] = "minecraft:knowledge_book";
+ // Paper end
+ }
+ }
+
+ private static class DataConverterArmorStand implements DataConverter {
+
+ DataConverterArmorStand() {
+ }
+
+ public int getDataVersion() {
+ return 147;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("ArmorStand".equals(cmp.getString("id")) && cmp.getBoolean("Silent") && !cmp.getBoolean("Marker")) {
+ cmp.remove("Silent");
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterBanner implements DataConverter {
+
+ DataConverterBanner() {
+ }
+
+ public int getDataVersion() {
+ return 804;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("minecraft:banner".equals(cmp.getString("id")) && cmp.contains("tag", 10)) {
+ CompoundTag nbttagcompound1 = cmp.getCompound("tag");
+
+ if (nbttagcompound1.contains("BlockEntityTag", 10)) {
+ CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
+
+ if (nbttagcompound2.contains("Base", 99)) {
+ cmp.putShort("Damage", (short) (nbttagcompound2.getShort("Base") & 15));
+ if (nbttagcompound1.contains("display", 10)) {
+ CompoundTag nbttagcompound3 = nbttagcompound1.getCompound("display");
+
+ if (nbttagcompound3.contains("Lore", 9)) {
+ ListTag nbttaglist = nbttagcompound3.getList("Lore", 8);
+
+ if (nbttaglist.size() == 1 && "(+NBT)".equals(nbttaglist.getString(0))) {
+ return cmp;
+ }
+ }
+ }
+
+ nbttagcompound2.remove("Base");
+ if (nbttagcompound2.isEmpty()) {
+ nbttagcompound1.remove("BlockEntityTag");
+ }
+
+ if (nbttagcompound1.isEmpty()) {
+ cmp.remove("tag");
+ }
+ }
+ }
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterPotionId implements DataConverter {
+
+ private static final String[] potions = new String[128];
+
+ DataConverterPotionId() {
+ }
+
+ public int getDataVersion() {
+ return 102;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("minecraft:potion".equals(cmp.getString("id"))) {
+ CompoundTag nbttagcompound1 = cmp.getCompound("tag");
+ short short0 = cmp.getShort("Damage");
+
+ if (!nbttagcompound1.contains("Potion", 8)) {
+ String s = DataConverterPotionId.potions[short0 & 127];
+
+ nbttagcompound1.putString("Potion", s == null ? "minecraft:water" : s);
+ cmp.put("tag", nbttagcompound1);
+ if ((short0 & 16384) == 16384) {
+ cmp.putString("id", "minecraft:splash_potion");
+ }
+ }
+
+ if (short0 != 0) {
+ cmp.putShort("Damage", (short) 0);
+ }
+ }
+
+ return cmp;
+ }
+
+ static {
+ DataConverterPotionId.potions[0] = "minecraft:water";
+ DataConverterPotionId.potions[1] = "minecraft:regeneration";
+ DataConverterPotionId.potions[2] = "minecraft:swiftness";
+ DataConverterPotionId.potions[3] = "minecraft:fire_resistance";
+ DataConverterPotionId.potions[4] = "minecraft:poison";
+ DataConverterPotionId.potions[5] = "minecraft:healing";
+ DataConverterPotionId.potions[6] = "minecraft:night_vision";
+ DataConverterPotionId.potions[7] = null;
+ DataConverterPotionId.potions[8] = "minecraft:weakness";
+ DataConverterPotionId.potions[9] = "minecraft:strength";
+ DataConverterPotionId.potions[10] = "minecraft:slowness";
+ DataConverterPotionId.potions[11] = "minecraft:leaping";
+ DataConverterPotionId.potions[12] = "minecraft:harming";
+ DataConverterPotionId.potions[13] = "minecraft:water_breathing";
+ DataConverterPotionId.potions[14] = "minecraft:invisibility";
+ DataConverterPotionId.potions[15] = null;
+ DataConverterPotionId.potions[16] = "minecraft:awkward";
+ DataConverterPotionId.potions[17] = "minecraft:regeneration";
+ DataConverterPotionId.potions[18] = "minecraft:swiftness";
+ DataConverterPotionId.potions[19] = "minecraft:fire_resistance";
+ DataConverterPotionId.potions[20] = "minecraft:poison";
+ DataConverterPotionId.potions[21] = "minecraft:healing";
+ DataConverterPotionId.potions[22] = "minecraft:night_vision";
+ DataConverterPotionId.potions[23] = null;
+ DataConverterPotionId.potions[24] = "minecraft:weakness";
+ DataConverterPotionId.potions[25] = "minecraft:strength";
+ DataConverterPotionId.potions[26] = "minecraft:slowness";
+ DataConverterPotionId.potions[27] = "minecraft:leaping";
+ DataConverterPotionId.potions[28] = "minecraft:harming";
+ DataConverterPotionId.potions[29] = "minecraft:water_breathing";
+ DataConverterPotionId.potions[30] = "minecraft:invisibility";
+ DataConverterPotionId.potions[31] = null;
+ DataConverterPotionId.potions[32] = "minecraft:thick";
+ DataConverterPotionId.potions[33] = "minecraft:strong_regeneration";
+ DataConverterPotionId.potions[34] = "minecraft:strong_swiftness";
+ DataConverterPotionId.potions[35] = "minecraft:fire_resistance";
+ DataConverterPotionId.potions[36] = "minecraft:strong_poison";
+ DataConverterPotionId.potions[37] = "minecraft:strong_healing";
+ DataConverterPotionId.potions[38] = "minecraft:night_vision";
+ DataConverterPotionId.potions[39] = null;
+ DataConverterPotionId.potions[40] = "minecraft:weakness";
+ DataConverterPotionId.potions[41] = "minecraft:strong_strength";
+ DataConverterPotionId.potions[42] = "minecraft:slowness";
+ DataConverterPotionId.potions[43] = "minecraft:strong_leaping";
+ DataConverterPotionId.potions[44] = "minecraft:strong_harming";
+ DataConverterPotionId.potions[45] = "minecraft:water_breathing";
+ DataConverterPotionId.potions[46] = "minecraft:invisibility";
+ DataConverterPotionId.potions[47] = null;
+ DataConverterPotionId.potions[48] = null;
+ DataConverterPotionId.potions[49] = "minecraft:strong_regeneration";
+ DataConverterPotionId.potions[50] = "minecraft:strong_swiftness";
+ DataConverterPotionId.potions[51] = "minecraft:fire_resistance";
+ DataConverterPotionId.potions[52] = "minecraft:strong_poison";
+ DataConverterPotionId.potions[53] = "minecraft:strong_healing";
+ DataConverterPotionId.potions[54] = "minecraft:night_vision";
+ DataConverterPotionId.potions[55] = null;
+ DataConverterPotionId.potions[56] = "minecraft:weakness";
+ DataConverterPotionId.potions[57] = "minecraft:strong_strength";
+ DataConverterPotionId.potions[58] = "minecraft:slowness";
+ DataConverterPotionId.potions[59] = "minecraft:strong_leaping";
+ DataConverterPotionId.potions[60] = "minecraft:strong_harming";
+ DataConverterPotionId.potions[61] = "minecraft:water_breathing";
+ DataConverterPotionId.potions[62] = "minecraft:invisibility";
+ DataConverterPotionId.potions[63] = null;
+ DataConverterPotionId.potions[64] = "minecraft:mundane";
+ DataConverterPotionId.potions[65] = "minecraft:long_regeneration";
+ DataConverterPotionId.potions[66] = "minecraft:long_swiftness";
+ DataConverterPotionId.potions[67] = "minecraft:long_fire_resistance";
+ DataConverterPotionId.potions[68] = "minecraft:long_poison";
+ DataConverterPotionId.potions[69] = "minecraft:healing";
+ DataConverterPotionId.potions[70] = "minecraft:long_night_vision";
+ DataConverterPotionId.potions[71] = null;
+ DataConverterPotionId.potions[72] = "minecraft:long_weakness";
+ DataConverterPotionId.potions[73] = "minecraft:long_strength";
+ DataConverterPotionId.potions[74] = "minecraft:long_slowness";
+ DataConverterPotionId.potions[75] = "minecraft:long_leaping";
+ DataConverterPotionId.potions[76] = "minecraft:harming";
+ DataConverterPotionId.potions[77] = "minecraft:long_water_breathing";
+ DataConverterPotionId.potions[78] = "minecraft:long_invisibility";
+ DataConverterPotionId.potions[79] = null;
+ DataConverterPotionId.potions[80] = "minecraft:awkward";
+ DataConverterPotionId.potions[81] = "minecraft:long_regeneration";
+ DataConverterPotionId.potions[82] = "minecraft:long_swiftness";
+ DataConverterPotionId.potions[83] = "minecraft:long_fire_resistance";
+ DataConverterPotionId.potions[84] = "minecraft:long_poison";
+ DataConverterPotionId.potions[85] = "minecraft:healing";
+ DataConverterPotionId.potions[86] = "minecraft:long_night_vision";
+ DataConverterPotionId.potions[87] = null;
+ DataConverterPotionId.potions[88] = "minecraft:long_weakness";
+ DataConverterPotionId.potions[89] = "minecraft:long_strength";
+ DataConverterPotionId.potions[90] = "minecraft:long_slowness";
+ DataConverterPotionId.potions[91] = "minecraft:long_leaping";
+ DataConverterPotionId.potions[92] = "minecraft:harming";
+ DataConverterPotionId.potions[93] = "minecraft:long_water_breathing";
+ DataConverterPotionId.potions[94] = "minecraft:long_invisibility";
+ DataConverterPotionId.potions[95] = null;
+ DataConverterPotionId.potions[96] = "minecraft:thick";
+ DataConverterPotionId.potions[97] = "minecraft:regeneration";
+ DataConverterPotionId.potions[98] = "minecraft:swiftness";
+ DataConverterPotionId.potions[99] = "minecraft:long_fire_resistance";
+ DataConverterPotionId.potions[100] = "minecraft:poison";
+ DataConverterPotionId.potions[101] = "minecraft:strong_healing";
+ DataConverterPotionId.potions[102] = "minecraft:long_night_vision";
+ DataConverterPotionId.potions[103] = null;
+ DataConverterPotionId.potions[104] = "minecraft:long_weakness";
+ DataConverterPotionId.potions[105] = "minecraft:strength";
+ DataConverterPotionId.potions[106] = "minecraft:long_slowness";
+ DataConverterPotionId.potions[107] = "minecraft:leaping";
+ DataConverterPotionId.potions[108] = "minecraft:strong_harming";
+ DataConverterPotionId.potions[109] = "minecraft:long_water_breathing";
+ DataConverterPotionId.potions[110] = "minecraft:long_invisibility";
+ DataConverterPotionId.potions[111] = null;
+ DataConverterPotionId.potions[112] = null;
+ DataConverterPotionId.potions[113] = "minecraft:regeneration";
+ DataConverterPotionId.potions[114] = "minecraft:swiftness";
+ DataConverterPotionId.potions[115] = "minecraft:long_fire_resistance";
+ DataConverterPotionId.potions[116] = "minecraft:poison";
+ DataConverterPotionId.potions[117] = "minecraft:strong_healing";
+ DataConverterPotionId.potions[118] = "minecraft:long_night_vision";
+ DataConverterPotionId.potions[119] = null;
+ DataConverterPotionId.potions[120] = "minecraft:long_weakness";
+ DataConverterPotionId.potions[121] = "minecraft:strength";
+ DataConverterPotionId.potions[122] = "minecraft:long_slowness";
+ DataConverterPotionId.potions[123] = "minecraft:leaping";
+ DataConverterPotionId.potions[124] = "minecraft:strong_harming";
+ DataConverterPotionId.potions[125] = "minecraft:long_water_breathing";
+ DataConverterPotionId.potions[126] = "minecraft:long_invisibility";
+ DataConverterPotionId.potions[127] = null;
+ }
+ }
+
+ private static class DataConverterSpawnEgg implements DataConverter {
+
+ private static final String[] eggs = new String[256];
+
+ DataConverterSpawnEgg() {
+ }
+
+ public int getDataVersion() {
+ return 105;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("minecraft:spawn_egg".equals(cmp.getString("id"))) {
+ CompoundTag nbttagcompound1 = cmp.getCompound("tag");
+ CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("EntityTag");
+ short short0 = cmp.getShort("Damage");
+
+ if (!nbttagcompound2.contains("id", 8)) {
+ String s = DataConverterSpawnEgg.eggs[short0 & 255];
+
+ if (s != null) {
+ nbttagcompound2.putString("id", s);
+ nbttagcompound1.put("EntityTag", nbttagcompound2);
+ cmp.put("tag", nbttagcompound1);
+ }
+ }
+
+ if (short0 != 0) {
+ cmp.putShort("Damage", (short) 0);
+ }
+ }
+
+ return cmp;
+ }
+
+ static {
+
+ DataConverterSpawnEgg.eggs[1] = "Item";
+ DataConverterSpawnEgg.eggs[2] = "XPOrb";
+ DataConverterSpawnEgg.eggs[7] = "ThrownEgg";
+ DataConverterSpawnEgg.eggs[8] = "LeashKnot";
+ DataConverterSpawnEgg.eggs[9] = "Painting";
+ DataConverterSpawnEgg.eggs[10] = "Arrow";
+ DataConverterSpawnEgg.eggs[11] = "Snowball";
+ DataConverterSpawnEgg.eggs[12] = "Fireball";
+ DataConverterSpawnEgg.eggs[13] = "SmallFireball";
+ DataConverterSpawnEgg.eggs[14] = "ThrownEnderpearl";
+ DataConverterSpawnEgg.eggs[15] = "EyeOfEnderSignal";
+ DataConverterSpawnEgg.eggs[16] = "ThrownPotion";
+ DataConverterSpawnEgg.eggs[17] = "ThrownExpBottle";
+ DataConverterSpawnEgg.eggs[18] = "ItemFrame";
+ DataConverterSpawnEgg.eggs[19] = "WitherSkull";
+ DataConverterSpawnEgg.eggs[20] = "PrimedTnt";
+ DataConverterSpawnEgg.eggs[21] = "FallingSand";
+ DataConverterSpawnEgg.eggs[22] = "FireworksRocketEntity";
+ DataConverterSpawnEgg.eggs[23] = "TippedArrow";
+ DataConverterSpawnEgg.eggs[24] = "SpectralArrow";
+ DataConverterSpawnEgg.eggs[25] = "ShulkerBullet";
+ DataConverterSpawnEgg.eggs[26] = "DragonFireball";
+ DataConverterSpawnEgg.eggs[30] = "ArmorStand";
+ DataConverterSpawnEgg.eggs[41] = "Boat";
+ DataConverterSpawnEgg.eggs[42] = "MinecartRideable";
+ DataConverterSpawnEgg.eggs[43] = "MinecartChest";
+ DataConverterSpawnEgg.eggs[44] = "MinecartFurnace";
+ DataConverterSpawnEgg.eggs[45] = "MinecartTNT";
+ DataConverterSpawnEgg.eggs[46] = "MinecartHopper";
+ DataConverterSpawnEgg.eggs[47] = "MinecartSpawner";
+ DataConverterSpawnEgg.eggs[40] = "MinecartCommandBlock";
+ DataConverterSpawnEgg.eggs[48] = "Mob";
+ DataConverterSpawnEgg.eggs[49] = "Monster";
+ DataConverterSpawnEgg.eggs[50] = "Creeper";
+ DataConverterSpawnEgg.eggs[51] = "Skeleton";
+ DataConverterSpawnEgg.eggs[52] = "Spider";
+ DataConverterSpawnEgg.eggs[53] = "Giant";
+ DataConverterSpawnEgg.eggs[54] = "Zombie";
+ DataConverterSpawnEgg.eggs[55] = "Slime";
+ DataConverterSpawnEgg.eggs[56] = "Ghast";
+ DataConverterSpawnEgg.eggs[57] = "PigZombie";
+ DataConverterSpawnEgg.eggs[58] = "Enderman";
+ DataConverterSpawnEgg.eggs[59] = "CaveSpider";
+ DataConverterSpawnEgg.eggs[60] = "Silverfish";
+ DataConverterSpawnEgg.eggs[61] = "Blaze";
+ DataConverterSpawnEgg.eggs[62] = "LavaSlime";
+ DataConverterSpawnEgg.eggs[63] = "EnderDragon";
+ DataConverterSpawnEgg.eggs[64] = "WitherBoss";
+ DataConverterSpawnEgg.eggs[65] = "Bat";
+ DataConverterSpawnEgg.eggs[66] = "Witch";
+ DataConverterSpawnEgg.eggs[67] = "Endermite";
+ DataConverterSpawnEgg.eggs[68] = "Guardian";
+ DataConverterSpawnEgg.eggs[69] = "Shulker";
+ DataConverterSpawnEgg.eggs[90] = "Pig";
+ DataConverterSpawnEgg.eggs[91] = "Sheep";
+ DataConverterSpawnEgg.eggs[92] = "Cow";
+ DataConverterSpawnEgg.eggs[93] = "Chicken";
+ DataConverterSpawnEgg.eggs[94] = "Squid";
+ DataConverterSpawnEgg.eggs[95] = "Wolf";
+ DataConverterSpawnEgg.eggs[96] = "MushroomCow";
+ DataConverterSpawnEgg.eggs[97] = "SnowMan";
+ DataConverterSpawnEgg.eggs[98] = "Ozelot";
+ DataConverterSpawnEgg.eggs[99] = "VillagerGolem";
+ DataConverterSpawnEgg.eggs[100] = "EntityHorse";
+ DataConverterSpawnEgg.eggs[101] = "Rabbit";
+ DataConverterSpawnEgg.eggs[120] = "Villager";
+ DataConverterSpawnEgg.eggs[200] = "EnderCrystal";
+ }
+ }
+
+ private static class DataConverterMinecart implements DataConverter {
+
+ private static final List a = Lists.newArrayList("MinecartRideable", "MinecartChest", "MinecartFurnace", "MinecartTNT", "MinecartSpawner", "MinecartHopper", "MinecartCommandBlock");
+
+ DataConverterMinecart() {
+ }
+
+ public int getDataVersion() {
+ return 106;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("Minecart".equals(cmp.getString("id"))) {
+ String s = "MinecartRideable";
+ int i = cmp.getInt("Type");
+
+ if (i > 0 && i < DataConverterMinecart.a.size()) {
+ s = DataConverterMinecart.a.get(i);
+ }
+
+ cmp.putString("id", s);
+ cmp.remove("Type");
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterMobSpawner implements DataConverter {
+
+ DataConverterMobSpawner() {
+ }
+
+ public int getDataVersion() {
+ return 107;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if (!"MobSpawner".equals(cmp.getString("id"))) {
+ return cmp;
+ } else {
+ if (cmp.contains("EntityId", 8)) {
+ String s = cmp.getString("EntityId");
+ CompoundTag nbttagcompound1 = cmp.getCompound("SpawnData");
+
+ nbttagcompound1.putString("id", s.isEmpty() ? "Pig" : s);
+ cmp.put("SpawnData", nbttagcompound1);
+ cmp.remove("EntityId");
+ }
+
+ if (cmp.contains("SpawnPotentials", 9)) {
+ ListTag nbttaglist = cmp.getList("SpawnPotentials", 10);
+
+ for (int i = 0; i < nbttaglist.size(); ++i) {
+ CompoundTag nbttagcompound2 = nbttaglist.getCompound(i);
+
+ if (nbttagcompound2.contains("Type", 8)) {
+ CompoundTag nbttagcompound3 = nbttagcompound2.getCompound("Properties");
+
+ nbttagcompound3.putString("id", nbttagcompound2.getString("Type"));
+ nbttagcompound2.put("Entity", nbttagcompound3);
+ nbttagcompound2.remove("Type");
+ nbttagcompound2.remove("Properties");
+ }
+ }
+ }
+
+ return cmp;
+ }
+ }
+ }
+
+ private static class DataConverterUUID implements DataConverter {
+
+ DataConverterUUID() {
+ }
+
+ public int getDataVersion() {
+ return 108;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if (cmp.contains("UUID", 8)) {
+ cmp.putUUID("UUID", UUID.fromString(cmp.getString("UUID")));
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterHealth implements DataConverter {
+
+ private static final Set a = Sets.newHashSet("ArmorStand", "Bat", "Blaze", "CaveSpider", "Chicken", "Cow", "Creeper", "EnderDragon", "Enderman", "Endermite", "EntityHorse", "Ghast", "Giant", "Guardian", "LavaSlime", "MushroomCow", "Ozelot", "Pig", "PigZombie", "Rabbit", "Sheep", "Shulker", "Silverfish", "Skeleton", "Slime", "SnowMan", "Spider", "Squid", "Villager", "VillagerGolem", "Witch", "WitherBoss", "Wolf", "Zombie");
+
+ DataConverterHealth() {
+ }
+
+ public int getDataVersion() {
+ return 109;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if (DataConverterHealth.a.contains(cmp.getString("id"))) {
+ float f;
+
+ if (cmp.contains("HealF", 99)) {
+ f = cmp.getFloat("HealF");
+ cmp.remove("HealF");
+ } else {
+ if (!cmp.contains("Health", 99)) {
+ return cmp;
+ }
+
+ f = cmp.getFloat("Health");
+ }
+
+ cmp.putFloat("Health", f);
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterSaddle implements DataConverter {
+
+ DataConverterSaddle() {
+ }
+
+ public int getDataVersion() {
+ return 110;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("EntityHorse".equals(cmp.getString("id")) && !cmp.contains("SaddleItem", 10) && cmp.getBoolean("Saddle")) {
+ CompoundTag nbttagcompound1 = new CompoundTag();
+
+ nbttagcompound1.putString("id", "minecraft:saddle");
+ nbttagcompound1.putByte("Count", (byte) 1);
+ nbttagcompound1.putShort("Damage", (short) 0);
+ cmp.put("SaddleItem", nbttagcompound1);
+ cmp.remove("Saddle");
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterHanging implements DataConverter {
+
+ DataConverterHanging() {
+ }
+
+ public int getDataVersion() {
+ return 111;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ String s = cmp.getString("id");
+ boolean flag = "Painting".equals(s);
+ boolean flag1 = "ItemFrame".equals(s);
+
+ if ((flag || flag1) && !cmp.contains("Facing", 99)) {
+ Direction enumdirection;
+
+ if (cmp.contains("Direction", 99)) {
+ enumdirection = Direction.from2DDataValue(cmp.getByte("Direction"));
+ cmp.putInt("TileX", cmp.getInt("TileX") + enumdirection.getStepX());
+ cmp.putInt("TileY", cmp.getInt("TileY") + enumdirection.getStepY());
+ cmp.putInt("TileZ", cmp.getInt("TileZ") + enumdirection.getStepZ());
+ cmp.remove("Direction");
+ if (flag1 && cmp.contains("ItemRotation", 99)) {
+ cmp.putByte("ItemRotation", (byte) (cmp.getByte("ItemRotation") * 2));
+ }
+ } else {
+ enumdirection = Direction.from2DDataValue(cmp.getByte("Dir"));
+ cmp.remove("Dir");
+ }
+
+ cmp.putByte("Facing", (byte) enumdirection.get2DDataValue());
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterDropChances implements DataConverter {
+
+ DataConverterDropChances() {
+ }
+
+ public int getDataVersion() {
+ return 113;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ ListTag nbttaglist;
+
+ if (cmp.contains("HandDropChances", 9)) {
+ nbttaglist = cmp.getList("HandDropChances", 5);
+ if (nbttaglist.size() == 2 && nbttaglist.getFloat(0) == 0.0F && nbttaglist.getFloat(1) == 0.0F) {
+ cmp.remove("HandDropChances");
+ }
+ }
+
+ if (cmp.contains("ArmorDropChances", 9)) {
+ nbttaglist = cmp.getList("ArmorDropChances", 5);
+ if (nbttaglist.size() == 4 && nbttaglist.getFloat(0) == 0.0F && nbttaglist.getFloat(1) == 0.0F && nbttaglist.getFloat(2) == 0.0F && nbttaglist.getFloat(3) == 0.0F) {
+ cmp.remove("ArmorDropChances");
+ }
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterRiding implements DataConverter {
+
+ DataConverterRiding() {
+ }
+
+ public int getDataVersion() {
+ return 135;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ while (cmp.contains("Riding", 10)) {
+ CompoundTag nbttagcompound1 = this.b(cmp);
+
+ this.convert(cmp, nbttagcompound1);
+ cmp = nbttagcompound1;
+ }
+
+ return cmp;
+ }
+
+ protected void convert(CompoundTag nbttagcompound, CompoundTag nbttagcompound1) {
+ ListTag nbttaglist = new ListTag();
+
+ nbttaglist.add(nbttagcompound);
+ nbttagcompound1.put("Passengers", nbttaglist);
+ }
+
+ protected CompoundTag b(CompoundTag nbttagcompound) {
+ CompoundTag nbttagcompound1 = nbttagcompound.getCompound("Riding");
+
+ nbttagcompound.remove("Riding");
+ return nbttagcompound1;
+ }
+ }
+
+ private static class DataConverterBook implements DataConverter {
+
+ DataConverterBook() {
+ }
+
+ public int getDataVersion() {
+ return 165;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("minecraft:written_book".equals(cmp.getString("id"))) {
+ CompoundTag nbttagcompound1 = cmp.getCompound("tag");
+
+ if (nbttagcompound1.contains("pages", 9)) {
+ ListTag nbttaglist = nbttagcompound1.getList("pages", 8);
+
+ for (int i = 0; i < nbttaglist.size(); ++i) {
+ String s = nbttaglist.getString(i);
+ Component object = null;
+
+ if (!"null".equals(s) && !StringUtil.isNullOrEmpty(s)) {
+ if ((s.charAt(0) != 34 || s.charAt(s.length() - 1) != 34) && (s.charAt(0) != 123 || s.charAt(s.length() - 1) != 125)) {
+ object = Component.literal(s);
+ } else {
+ try {
+ object = GsonHelper.fromJson(DataConverterSignText.a, s, Component.class, true);
+ if (object == null) {
+ object = Component.literal("");
+ }
+ } catch (JsonParseException jsonparseexception) {
+ ;
+ }
+
+ if (object == null) {
+ try {
+ object = Component.Serializer.fromJson(s, MinecraftServer.getServer().registryAccess());
+ } catch (JsonParseException jsonparseexception1) {
+ ;
+ }
+ }
+
+ if (object == null) {
+ try {
+ object = Component.Serializer.fromJsonLenient(s, MinecraftServer.getServer().registryAccess());
+ } catch (JsonParseException jsonparseexception2) {
+ ;
+ }
+ }
+
+ if (object == null) {
+ object = Component.literal(s);
+ }
+ }
+ } else {
+ object = Component.literal("");
+ }
+
+ nbttaglist.set(i, StringTag.valueOf(Component.Serializer.toJson(object, MinecraftServer.getServer().registryAccess())));
+ }
+
+ nbttagcompound1.put("pages", nbttaglist);
+ }
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterCookedFish implements DataConverter {
+
+ private static final ResourceLocation a = new ResourceLocation("cooked_fished");
+
+ DataConverterCookedFish() {
+ }
+
+ public int getDataVersion() {
+ return 502;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if (cmp.contains("id", 8) && DataConverterCookedFish.a.equals(new ResourceLocation(cmp.getString("id")))) {
+ cmp.putString("id", "minecraft:cooked_fish");
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterZombie implements DataConverter {
+
+ private static final Random a = new Random();
+
+ DataConverterZombie() {
+ }
+
+ public int getDataVersion() {
+ return 502;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("Zombie".equals(cmp.getString("id")) && cmp.getBoolean("IsVillager")) {
+ if (!cmp.contains("ZombieType", 99)) {
+ int i = -1;
+
+ if (cmp.contains("VillagerProfession", 99)) {
+ try {
+ i = this.convert(cmp.getInt("VillagerProfession"));
+ } catch (RuntimeException runtimeexception) {
+ ;
+ }
+ }
+
+ if (i == -1) {
+ i = this.convert(DataConverterZombie.a.nextInt(6));
+ }
+
+ cmp.putInt("ZombieType", i);
+ }
+
+ cmp.remove("IsVillager");
+ }
+
+ return cmp;
+ }
+
+ private int convert(int i) {
+ return i >= 0 && i < 6 ? i : -1;
+ }
+ }
+
+ private static class DataConverterVBO implements DataConverter {
+
+ DataConverterVBO() {
+ }
+
+ public int getDataVersion() {
+ return 505;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ cmp.putString("useVbo", "true");
+ return cmp;
+ }
+ }
+
+ private static class DataConverterGuardian implements DataConverter {
+
+ DataConverterGuardian() {
+ }
+
+ public int getDataVersion() {
+ return 700;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("Guardian".equals(cmp.getString("id"))) {
+ if (cmp.getBoolean("Elder")) {
+ cmp.putString("id", "ElderGuardian");
+ }
+
+ cmp.remove("Elder");
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterSkeleton implements DataConverter {
+
+ DataConverterSkeleton() {
+ }
+
+ public int getDataVersion() {
+ return 701;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ String s = cmp.getString("id");
+
+ if ("Skeleton".equals(s)) {
+ int i = cmp.getInt("SkeletonType");
+
+ if (i == 1) {
+ cmp.putString("id", "WitherSkeleton");
+ } else if (i == 2) {
+ cmp.putString("id", "Stray");
+ }
+
+ cmp.remove("SkeletonType");
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterZombieType implements DataConverter {
+
+ DataConverterZombieType() {
+ }
+
+ public int getDataVersion() {
+ return 702;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("Zombie".equals(cmp.getString("id"))) {
+ int i = cmp.getInt("ZombieType");
+
+ switch (i) {
+ case 0:
+ default:
+ break;
+
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ cmp.putString("id", "ZombieVillager");
+ cmp.putInt("Profession", i - 1);
+ break;
+
+ case 6:
+ cmp.putString("id", "Husk");
+ }
+
+ cmp.remove("ZombieType");
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterHorse implements DataConverter {
+
+ DataConverterHorse() {
+ }
+
+ public int getDataVersion() {
+ return 703;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("EntityHorse".equals(cmp.getString("id"))) {
+ int i = cmp.getInt("Type");
+
+ switch (i) {
+ case 0:
+ default:
+ cmp.putString("id", "Horse");
+ break;
+
+ case 1:
+ cmp.putString("id", "Donkey");
+ break;
+
+ case 2:
+ cmp.putString("id", "Mule");
+ break;
+
+ case 3:
+ cmp.putString("id", "ZombieHorse");
+ break;
+
+ case 4:
+ cmp.putString("id", "SkeletonHorse");
+ }
+
+ cmp.remove("Type");
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterTileEntity implements DataConverter {
+
+ private static final Map a = Maps.newHashMap();
+
+ DataConverterTileEntity() {
+ }
+
+ public int getDataVersion() {
+ return 704;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ String s = DataConverterTileEntity.a.get(cmp.getString("id"));
+
+ if (s != null) {
+ cmp.putString("id", s);
+ }
+
+ return cmp;
+ }
+
+ static {
+ DataConverterTileEntity.a.put("Airportal", "minecraft:end_portal");
+ DataConverterTileEntity.a.put("Banner", "minecraft:banner");
+ DataConverterTileEntity.a.put("Beacon", "minecraft:beacon");
+ DataConverterTileEntity.a.put("Cauldron", "minecraft:brewing_stand");
+ DataConverterTileEntity.a.put("Chest", "minecraft:chest");
+ DataConverterTileEntity.a.put("Comparator", "minecraft:comparator");
+ DataConverterTileEntity.a.put("Control", "minecraft:command_block");
+ DataConverterTileEntity.a.put("DLDetector", "minecraft:daylight_detector");
+ DataConverterTileEntity.a.put("Dropper", "minecraft:dropper");
+ DataConverterTileEntity.a.put("EnchantTable", "minecraft:enchanting_table");
+ DataConverterTileEntity.a.put("EndGateway", "minecraft:end_gateway");
+ DataConverterTileEntity.a.put("EnderChest", "minecraft:ender_chest");
+ DataConverterTileEntity.a.put("FlowerPot", "minecraft:flower_pot");
+ DataConverterTileEntity.a.put("Furnace", "minecraft:furnace");
+ DataConverterTileEntity.a.put("Hopper", "minecraft:hopper");
+ DataConverterTileEntity.a.put("MobSpawner", "minecraft:mob_spawner");
+ DataConverterTileEntity.a.put("Music", "minecraft:noteblock");
+ DataConverterTileEntity.a.put("Piston", "minecraft:piston");
+ DataConverterTileEntity.a.put("RecordPlayer", "minecraft:jukebox");
+ DataConverterTileEntity.a.put("Sign", "minecraft:sign");
+ DataConverterTileEntity.a.put("Skull", "minecraft:skull");
+ DataConverterTileEntity.a.put("Structure", "minecraft:structure_block");
+ DataConverterTileEntity.a.put("Trap", "minecraft:dispenser");
+ }
+ }
+
+ private static class DataConverterEntity implements DataConverter {
+
+ private static final Map a = Maps.newHashMap();
+
+ DataConverterEntity() {
+ }
+
+ public int getDataVersion() {
+ return 704;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ String s = DataConverterEntity.a.get(cmp.getString("id"));
+
+ if (s != null) {
+ cmp.putString("id", s);
+ }
+
+ return cmp;
+ }
+
+ static {
+ DataConverterEntity.a.put("AreaEffectCloud", "minecraft:area_effect_cloud");
+ DataConverterEntity.a.put("ArmorStand", "minecraft:armor_stand");
+ DataConverterEntity.a.put("Arrow", "minecraft:arrow");
+ DataConverterEntity.a.put("Bat", "minecraft:bat");
+ DataConverterEntity.a.put("Blaze", "minecraft:blaze");
+ DataConverterEntity.a.put("Boat", "minecraft:boat");
+ DataConverterEntity.a.put("CaveSpider", "minecraft:cave_spider");
+ DataConverterEntity.a.put("Chicken", "minecraft:chicken");
+ DataConverterEntity.a.put("Cow", "minecraft:cow");
+ DataConverterEntity.a.put("Creeper", "minecraft:creeper");
+ DataConverterEntity.a.put("Donkey", "minecraft:donkey");
+ DataConverterEntity.a.put("DragonFireball", "minecraft:dragon_fireball");
+ DataConverterEntity.a.put("ElderGuardian", "minecraft:elder_guardian");
+ DataConverterEntity.a.put("EnderCrystal", "minecraft:ender_crystal");
+ DataConverterEntity.a.put("EnderDragon", "minecraft:ender_dragon");
+ DataConverterEntity.a.put("Enderman", "minecraft:enderman");
+ DataConverterEntity.a.put("Endermite", "minecraft:endermite");
+ DataConverterEntity.a.put("EyeOfEnderSignal", "minecraft:eye_of_ender_signal");
+ DataConverterEntity.a.put("FallingSand", "minecraft:falling_block");
+ DataConverterEntity.a.put("Fireball", "minecraft:fireball");
+ DataConverterEntity.a.put("FireworksRocketEntity", "minecraft:fireworks_rocket");
+ DataConverterEntity.a.put("Ghast", "minecraft:ghast");
+ DataConverterEntity.a.put("Giant", "minecraft:giant");
+ DataConverterEntity.a.put("Guardian", "minecraft:guardian");
+ DataConverterEntity.a.put("Horse", "minecraft:horse");
+ DataConverterEntity.a.put("Husk", "minecraft:husk");
+ DataConverterEntity.a.put("Item", "minecraft:item");
+ DataConverterEntity.a.put("ItemFrame", "minecraft:item_frame");
+ DataConverterEntity.a.put("LavaSlime", "minecraft:magma_cube");
+ DataConverterEntity.a.put("LeashKnot", "minecraft:leash_knot");
+ DataConverterEntity.a.put("MinecartChest", "minecraft:chest_minecart");
+ DataConverterEntity.a.put("MinecartCommandBlock", "minecraft:commandblock_minecart");
+ DataConverterEntity.a.put("MinecartFurnace", "minecraft:furnace_minecart");
+ DataConverterEntity.a.put("MinecartHopper", "minecraft:hopper_minecart");
+ DataConverterEntity.a.put("MinecartRideable", "minecraft:minecart");
+ DataConverterEntity.a.put("MinecartSpawner", "minecraft:spawner_minecart");
+ DataConverterEntity.a.put("MinecartTNT", "minecraft:tnt_minecart");
+ DataConverterEntity.a.put("Mule", "minecraft:mule");
+ DataConverterEntity.a.put("MushroomCow", "minecraft:mooshroom");
+ DataConverterEntity.a.put("Ozelot", "minecraft:ocelot");
+ DataConverterEntity.a.put("Painting", "minecraft:painting");
+ DataConverterEntity.a.put("Pig", "minecraft:pig");
+ DataConverterEntity.a.put("PigZombie", "minecraft:zombie_pigman");
+ DataConverterEntity.a.put("PolarBear", "minecraft:polar_bear");
+ DataConverterEntity.a.put("PrimedTnt", "minecraft:tnt");
+ DataConverterEntity.a.put("Rabbit", "minecraft:rabbit");
+ DataConverterEntity.a.put("Sheep", "minecraft:sheep");
+ DataConverterEntity.a.put("Shulker", "minecraft:shulker");
+ DataConverterEntity.a.put("ShulkerBullet", "minecraft:shulker_bullet");
+ DataConverterEntity.a.put("Silverfish", "minecraft:silverfish");
+ DataConverterEntity.a.put("Skeleton", "minecraft:skeleton");
+ DataConverterEntity.a.put("SkeletonHorse", "minecraft:skeleton_horse");
+ DataConverterEntity.a.put("Slime", "minecraft:slime");
+ DataConverterEntity.a.put("SmallFireball", "minecraft:small_fireball");
+ DataConverterEntity.a.put("SnowMan", "minecraft:snowman");
+ DataConverterEntity.a.put("Snowball", "minecraft:snowball");
+ DataConverterEntity.a.put("SpectralArrow", "minecraft:spectral_arrow");
+ DataConverterEntity.a.put("Spider", "minecraft:spider");
+ DataConverterEntity.a.put("Squid", "minecraft:squid");
+ DataConverterEntity.a.put("Stray", "minecraft:stray");
+ DataConverterEntity.a.put("ThrownEgg", "minecraft:egg");
+ DataConverterEntity.a.put("ThrownEnderpearl", "minecraft:ender_pearl");
+ DataConverterEntity.a.put("ThrownExpBottle", "minecraft:xp_bottle");
+ DataConverterEntity.a.put("ThrownPotion", "minecraft:potion");
+ DataConverterEntity.a.put("Villager", "minecraft:villager");
+ DataConverterEntity.a.put("VillagerGolem", "minecraft:villager_golem");
+ DataConverterEntity.a.put("Witch", "minecraft:witch");
+ DataConverterEntity.a.put("WitherBoss", "minecraft:wither");
+ DataConverterEntity.a.put("WitherSkeleton", "minecraft:wither_skeleton");
+ DataConverterEntity.a.put("WitherSkull", "minecraft:wither_skull");
+ DataConverterEntity.a.put("Wolf", "minecraft:wolf");
+ DataConverterEntity.a.put("XPOrb", "minecraft:xp_orb");
+ DataConverterEntity.a.put("Zombie", "minecraft:zombie");
+ DataConverterEntity.a.put("ZombieHorse", "minecraft:zombie_horse");
+ DataConverterEntity.a.put("ZombieVillager", "minecraft:zombie_villager");
+ }
+ }
+
+ private static class DataConverterPotionWater implements DataConverter {
+
+ DataConverterPotionWater() {
+ }
+
+ public int getDataVersion() {
+ return 806;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ String s = cmp.getString("id");
+
+ if ("minecraft:potion".equals(s) || "minecraft:splash_potion".equals(s) || "minecraft:lingering_potion".equals(s) || "minecraft:tipped_arrow".equals(s)) {
+ CompoundTag nbttagcompound1 = cmp.getCompound("tag");
+
+ if (!nbttagcompound1.contains("Potion", 8)) {
+ nbttagcompound1.putString("Potion", "minecraft:water");
+ }
+
+ if (!cmp.contains("tag", 10)) {
+ cmp.put("tag", nbttagcompound1);
+ }
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterShulker implements DataConverter {
+
+ DataConverterShulker() {
+ }
+
+ public int getDataVersion() {
+ return 808;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("minecraft:shulker".equals(cmp.getString("id")) && !cmp.contains("Color", 99)) {
+ cmp.putByte("Color", (byte) 10);
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterShulkerBoxItem implements DataConverter {
+
+ public static final String[] a = new String[] { "minecraft:white_shulker_box", "minecraft:orange_shulker_box", "minecraft:magenta_shulker_box", "minecraft:light_blue_shulker_box", "minecraft:yellow_shulker_box", "minecraft:lime_shulker_box", "minecraft:pink_shulker_box", "minecraft:gray_shulker_box", "minecraft:silver_shulker_box", "minecraft:cyan_shulker_box", "minecraft:purple_shulker_box", "minecraft:blue_shulker_box", "minecraft:brown_shulker_box", "minecraft:green_shulker_box", "minecraft:red_shulker_box", "minecraft:black_shulker_box" };
+
+ DataConverterShulkerBoxItem() {
+ }
+
+ public int getDataVersion() {
+ return 813;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("minecraft:shulker_box".equals(cmp.getString("id")) && cmp.contains("tag", 10)) {
+ CompoundTag nbttagcompound1 = cmp.getCompound("tag");
+
+ if (nbttagcompound1.contains("BlockEntityTag", 10)) {
+ CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
+
+ if (nbttagcompound2.getList("Items", 10).isEmpty()) {
+ nbttagcompound2.remove("Items");
+ }
+
+ int i = nbttagcompound2.getInt("Color");
+
+ nbttagcompound2.remove("Color");
+ if (nbttagcompound2.isEmpty()) {
+ nbttagcompound1.remove("BlockEntityTag");
+ }
+
+ if (nbttagcompound1.isEmpty()) {
+ cmp.remove("tag");
+ }
+
+ cmp.putString("id", DataConverterShulkerBoxItem.a[i % 16]);
+ }
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterShulkerBoxBlock implements DataConverter {
+
+ DataConverterShulkerBoxBlock() {
+ }
+
+ public int getDataVersion() {
+ return 813;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("minecraft:shulker".equals(cmp.getString("id"))) {
+ cmp.remove("Color");
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterLang implements DataConverter {
+
+ DataConverterLang() {
+ }
+
+ public int getDataVersion() {
+ return 816;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if (cmp.contains("lang", 8)) {
+ cmp.putString("lang", cmp.getString("lang").toLowerCase(Locale.ROOT));
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterTotem implements DataConverter {
+
+ DataConverterTotem() {
+ }
+
+ public int getDataVersion() {
+ return 820;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("minecraft:totem".equals(cmp.getString("id"))) {
+ cmp.putString("id", "minecraft:totem_of_undying");
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterBedBlock implements DataConverter {
+
+ private static final Logger a = LogManager.getLogger(PaperweightDataConverters.class);
+
+ DataConverterBedBlock() {
+ }
+
+ public int getDataVersion() {
+ return 1125;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ try {
+ CompoundTag nbttagcompound1 = cmp.getCompound("Level");
+ int i = nbttagcompound1.getInt("xPos");
+ int j = nbttagcompound1.getInt("zPos");
+ ListTag nbttaglist = nbttagcompound1.getList("TileEntities", 10);
+ ListTag nbttaglist1 = nbttagcompound1.getList("Sections", 10);
+
+ for (int k = 0; k < nbttaglist1.size(); ++k) {
+ CompoundTag nbttagcompound2 = nbttaglist1.getCompound(k);
+ byte b0 = nbttagcompound2.getByte("Y");
+ byte[] abyte = nbttagcompound2.getByteArray("Blocks");
+
+ for (int l = 0; l < abyte.length; ++l) {
+ if (416 == (abyte[l] & 255) << 4) {
+ int i1 = l & 15;
+ int j1 = l >> 8 & 15;
+ int k1 = l >> 4 & 15;
+ CompoundTag nbttagcompound3 = new CompoundTag();
+
+ nbttagcompound3.putString("id", "bed");
+ nbttagcompound3.putInt("x", i1 + (i << 4));
+ nbttagcompound3.putInt("y", j1 + (b0 << 4));
+ nbttagcompound3.putInt("z", k1 + (j << 4));
+ nbttaglist.add(nbttagcompound3);
+ }
+ }
+ }
+ } catch (Exception exception) {
+ DataConverterBedBlock.a.warn("Unable to datafix Bed blocks, level format may be missing tags.");
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterBedItem implements DataConverter {
+
+ DataConverterBedItem() {
+ }
+
+ public int getDataVersion() {
+ return 1125;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("minecraft:bed".equals(cmp.getString("id")) && cmp.getShort("Damage") == 0) {
+ cmp.putShort("Damage", (short) DyeColor.RED.getId());
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataConverterSignText implements DataConverter {
+
+ public static final Gson a = new GsonBuilder().registerTypeAdapter(Component.class, new JsonDeserializer() {
+ MutableComponent a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
+ if (jsonelement.isJsonPrimitive()) {
+ return Component.literal(jsonelement.getAsString());
+ } else if (jsonelement.isJsonArray()) {
+ JsonArray jsonarray = jsonelement.getAsJsonArray();
+ MutableComponent ichatbasecomponent = null;
+ Iterator iterator = jsonarray.iterator();
+
+ while (iterator.hasNext()) {
+ JsonElement jsonelement1 = (JsonElement) iterator.next();
+ MutableComponent ichatbasecomponent1 = this.a(jsonelement1, jsonelement1.getClass(), jsondeserializationcontext);
+
+ if (ichatbasecomponent == null) {
+ ichatbasecomponent = ichatbasecomponent1;
+ } else {
+ ichatbasecomponent.append(ichatbasecomponent1);
+ }
+ }
+
+ return ichatbasecomponent;
+ } else {
+ throw new JsonParseException("Don't know how to turn " + jsonelement + " into a Component");
+ }
+ }
+
+ public Object deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
+ return this.a(jsonelement, type, jsondeserializationcontext);
+ }
+ }).create();
+
+ DataConverterSignText() {
+ }
+
+ public int getDataVersion() {
+ return 101;
+ }
+
+ public CompoundTag convert(CompoundTag cmp) {
+ if ("Sign".equals(cmp.getString("id"))) {
+ this.convert(cmp, "Text1");
+ this.convert(cmp, "Text2");
+ this.convert(cmp, "Text3");
+ this.convert(cmp, "Text4");
+ }
+
+ return cmp;
+ }
+
+ private void convert(CompoundTag nbttagcompound, String s) {
+ String s1 = nbttagcompound.getString(s);
+ Component object = null;
+
+ if (!"null".equals(s1) && !StringUtil.isNullOrEmpty(s1)) {
+ if ((s1.charAt(0) != 34 || s1.charAt(s1.length() - 1) != 34) && (s1.charAt(0) != 123 || s1.charAt(s1.length() - 1) != 125)) {
+ object = Component.literal(s1);
+ } else {
+ try {
+ object = GsonHelper.fromJson(DataConverterSignText.a, s1, Component.class, true);
+ if (object == null) {
+ object = Component.literal("");
+ }
+ } catch (JsonParseException jsonparseexception) {
+ ;
+ }
+
+ if (object == null) {
+ try {
+ object = Component.Serializer.fromJson(s1, MinecraftServer.getServer().registryAccess());
+ } catch (JsonParseException jsonparseexception1) {
+ ;
+ }
+ }
+
+ if (object == null) {
+ try {
+ object = Component.Serializer.fromJsonLenient(s1, MinecraftServer.getServer().registryAccess());
+ } catch (JsonParseException jsonparseexception2) {
+ ;
+ }
+ }
+
+ if (object == null) {
+ object = Component.literal(s1);
+ }
+ }
+ } else {
+ object = Component.literal("");
+ }
+
+ nbttagcompound.putString(s, Component.Serializer.toJson(object, MinecraftServer.getServer().registryAccess()));
+ }
+ }
+
+ private static class DataInspectorPlayerVehicle implements DataInspector {
+ @Override
+ public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
+ if (cmp.contains("RootVehicle", 10)) {
+ CompoundTag nbttagcompound1 = cmp.getCompound("RootVehicle");
+
+ if (nbttagcompound1.contains("Entity", 10)) {
+ convertCompound(LegacyType.ENTITY, nbttagcompound1, "Entity", sourceVer, targetVer);
+ }
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataInspectorLevelPlayer implements DataInspector {
+ @Override
+ public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
+ if (cmp.contains("Player", 10)) {
+ convertCompound(LegacyType.PLAYER, cmp, "Player", sourceVer, targetVer);
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataInspectorStructure implements DataInspector {
+ @Override
+ public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
+ ListTag nbttaglist;
+ int j;
+ CompoundTag nbttagcompound1;
+
+ if (cmp.contains("entities", 9)) {
+ nbttaglist = cmp.getList("entities", 10);
+
+ for (j = 0; j < nbttaglist.size(); ++j) {
+ nbttagcompound1 = (CompoundTag) nbttaglist.get(j);
+ if (nbttagcompound1.contains("nbt", 10)) {
+ convertCompound(LegacyType.ENTITY, nbttagcompound1, "nbt", sourceVer, targetVer);
+ }
+ }
+ }
+
+ if (cmp.contains("blocks", 9)) {
+ nbttaglist = cmp.getList("blocks", 10);
+
+ for (j = 0; j < nbttaglist.size(); ++j) {
+ nbttagcompound1 = (CompoundTag) nbttaglist.get(j);
+ if (nbttagcompound1.contains("nbt", 10)) {
+ convertCompound(LegacyType.BLOCK_ENTITY, nbttagcompound1, "nbt", sourceVer, targetVer);
+ }
+ }
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataInspectorChunks implements DataInspector {
+ @Override
+ public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
+ if (cmp.contains("Level", 10)) {
+ CompoundTag nbttagcompound1 = cmp.getCompound("Level");
+ ListTag nbttaglist;
+ int j;
+
+ if (nbttagcompound1.contains("Entities", 9)) {
+ nbttaglist = nbttagcompound1.getList("Entities", 10);
+
+ for (j = 0; j < nbttaglist.size(); ++j) {
+ nbttaglist.set(j, convert(LegacyType.ENTITY, (CompoundTag) nbttaglist.get(j), sourceVer, targetVer));
+ }
+ }
+
+ if (nbttagcompound1.contains("TileEntities", 9)) {
+ nbttaglist = nbttagcompound1.getList("TileEntities", 10);
+
+ for (j = 0; j < nbttaglist.size(); ++j) {
+ nbttaglist.set(j, convert(LegacyType.BLOCK_ENTITY, (CompoundTag) nbttaglist.get(j), sourceVer, targetVer));
+ }
+ }
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataInspectorEntityPassengers implements DataInspector {
+ @Override
+ public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
+ if (cmp.contains("Passengers", 9)) {
+ ListTag nbttaglist = cmp.getList("Passengers", 10);
+
+ for (int j = 0; j < nbttaglist.size(); ++j) {
+ nbttaglist.set(j, convert(LegacyType.ENTITY, nbttaglist.getCompound(j), sourceVer, targetVer));
+ }
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataInspectorPlayer implements DataInspector {
+ @Override
+ public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
+ convertItems(cmp, "Inventory", sourceVer, targetVer);
+ convertItems(cmp, "EnderItems", sourceVer, targetVer);
+ if (cmp.contains("ShoulderEntityLeft", 10)) {
+ convertCompound(LegacyType.ENTITY, cmp, "ShoulderEntityLeft", sourceVer, targetVer);
+ }
+
+ if (cmp.contains("ShoulderEntityRight", 10)) {
+ convertCompound(LegacyType.ENTITY, cmp, "ShoulderEntityRight", sourceVer, targetVer);
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataInspectorVillagers implements DataInspector {
+ ResourceLocation entityVillager = getKey("EntityVillager");
+
+ @Override
+ public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
+ if (entityVillager.equals(new ResourceLocation(cmp.getString("id"))) && cmp.contains("Offers", 10)) {
+ CompoundTag nbttagcompound1 = cmp.getCompound("Offers");
+
+ if (nbttagcompound1.contains("Recipes", 9)) {
+ ListTag nbttaglist = nbttagcompound1.getList("Recipes", 10);
+
+ for (int j = 0; j < nbttaglist.size(); ++j) {
+ CompoundTag nbttagcompound2 = nbttaglist.getCompound(j);
+
+ convertItem(nbttagcompound2, "buy", sourceVer, targetVer);
+ convertItem(nbttagcompound2, "buyB", sourceVer, targetVer);
+ convertItem(nbttagcompound2, "sell", sourceVer, targetVer);
+ nbttaglist.set(j, nbttagcompound2);
+ }
+ }
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataInspectorMobSpawnerMinecart implements DataInspector {
+ ResourceLocation entityMinecartMobSpawner = getKey("EntityMinecartMobSpawner");
+ ResourceLocation tileEntityMobSpawner = getKey("TileEntityMobSpawner");
+
+ @Override
+ public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
+ String s = cmp.getString("id");
+ if (entityMinecartMobSpawner.equals(new ResourceLocation(s))) {
+ cmp.putString("id", tileEntityMobSpawner.toString());
+ convert(LegacyType.BLOCK_ENTITY, cmp, sourceVer, targetVer);
+ cmp.putString("id", s);
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataInspectorMobSpawnerMobs implements DataInspector {
+ ResourceLocation tileEntityMobSpawner = getKey("TileEntityMobSpawner");
+
+ @Override
+ public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
+ if (tileEntityMobSpawner.equals(new ResourceLocation(cmp.getString("id")))) {
+ if (cmp.contains("SpawnPotentials", 9)) {
+ ListTag nbttaglist = cmp.getList("SpawnPotentials", 10);
+
+ for (int j = 0; j < nbttaglist.size(); ++j) {
+ CompoundTag nbttagcompound1 = nbttaglist.getCompound(j);
+
+ convertCompound(LegacyType.ENTITY, nbttagcompound1, "Entity", sourceVer, targetVer);
+ }
+ }
+
+ convertCompound(LegacyType.ENTITY, cmp, "SpawnData", sourceVer, targetVer);
+ }
+
+ return cmp;
+ }
+ }
+
+ private static class DataInspectorCommandBlock implements DataInspector {
+ ResourceLocation tileEntityCommand = getKey("TileEntityCommand");
+
+ @Override
+ public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
+ if (tileEntityCommand.equals(new ResourceLocation(cmp.getString("id")))) {
+ cmp.putString("id", "Control");
+ convert(LegacyType.BLOCK_ENTITY, cmp, sourceVer, targetVer);
+ cmp.putString("id", "MinecartCommandBlock");
+ }
+
+ return cmp;
+ }
+ }
+}
diff --git a/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightFakePlayer.java b/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightFakePlayer.java
new file mode 100644
index 0000000000..2875db4240
--- /dev/null
+++ b/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightFakePlayer.java
@@ -0,0 +1,98 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.bukkit.adapter.impl.v1_20_R4;
+
+import com.mojang.authlib.GameProfile;
+import net.minecraft.network.chat.Component;
+import net.minecraft.server.level.ClientInformation;
+import net.minecraft.server.level.ServerLevel;
+import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.stats.Stat;
+import net.minecraft.world.MenuProvider;
+import net.minecraft.world.damagesource.DamageSource;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.HumanoidArm;
+import net.minecraft.world.entity.player.ChatVisiblity;
+import net.minecraft.world.level.block.entity.SignBlockEntity;
+import net.minecraft.world.phys.Vec3;
+import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
+
+import java.util.OptionalInt;
+import java.util.UUID;
+
+class PaperweightFakePlayer extends ServerPlayer {
+ private static final GameProfile FAKE_WORLDEDIT_PROFILE = new GameProfile(UUID.nameUUIDFromBytes("worldedit".getBytes()), "[WorldEdit]");
+ private static final Vec3 ORIGIN = new Vec3(0.0D, 0.0D, 0.0D);
+ private static final ClientInformation FAKE_CLIENT_INFO = new ClientInformation(
+ "en_US", 16, ChatVisiblity.FULL, true, 0, HumanoidArm.LEFT, false, false
+ );
+
+ PaperweightFakePlayer(ServerLevel world) {
+ super(world.getServer(), world, FAKE_WORLDEDIT_PROFILE, FAKE_CLIENT_INFO);
+ }
+
+ @Override
+ public Vec3 position() {
+ return ORIGIN;
+ }
+
+ @Override
+ public void tick() {
+ }
+
+ @Override
+ public void die(DamageSource damagesource) {
+ }
+
+ @Override
+ public Entity changeDimension(ServerLevel worldserver, TeleportCause cause) {
+ return this;
+ }
+
+ @Override
+ public OptionalInt openMenu(MenuProvider factory) {
+ return OptionalInt.empty();
+ }
+
+ @Override
+ public void updateOptions(ClientInformation clientOptions) {
+ }
+
+ @Override
+ public void displayClientMessage(Component message, boolean actionBar) {
+ }
+
+ @Override
+ public void awardStat(Stat> stat, int amount) {
+ }
+
+ @Override
+ public void awardStat(Stat> stat) {
+ }
+
+ @Override
+ public boolean isInvulnerableTo(DamageSource damageSource) {
+ return true;
+ }
+
+ @Override
+ public void openTextEdit(SignBlockEntity sign, boolean front) {
+ }
+}
diff --git a/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightServerLevelDelegateProxy.java b/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightServerLevelDelegateProxy.java
new file mode 100644
index 0000000000..b567aacf64
--- /dev/null
+++ b/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightServerLevelDelegateProxy.java
@@ -0,0 +1,153 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.bukkit.adapter.impl.v1_20_R4;
+
+import com.sk89q.worldedit.EditSession;
+import com.sk89q.worldedit.MaxChangedBlocksException;
+import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldedit.entity.BaseEntity;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.util.Location;
+import com.sk89q.worldedit.util.concurrency.LazyReference;
+import com.sk89q.worldedit.world.block.BlockTypes;
+import com.sk89q.worldedit.world.entity.EntityTypes;
+import net.minecraft.core.BlockPos;
+import net.minecraft.core.registries.Registries;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.level.ServerLevel;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.level.WorldGenLevel;
+import net.minecraft.world.level.block.entity.BlockEntity;
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.phys.Vec3;
+import org.enginehub.linbus.tree.LinCompoundTag;
+import org.jetbrains.annotations.Nullable;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+public class PaperweightServerLevelDelegateProxy implements InvocationHandler {
+
+ private final EditSession editSession;
+ private final ServerLevel serverLevel;
+ private final PaperweightAdapter adapter;
+
+ private PaperweightServerLevelDelegateProxy(EditSession editSession, ServerLevel serverLevel, PaperweightAdapter adapter) {
+ this.editSession = editSession;
+ this.serverLevel = serverLevel;
+ this.adapter = adapter;
+ }
+
+ public static WorldGenLevel newInstance(EditSession editSession, ServerLevel serverLevel, PaperweightAdapter adapter) {
+ return (WorldGenLevel) Proxy.newProxyInstance(
+ serverLevel.getClass().getClassLoader(),
+ serverLevel.getClass().getInterfaces(),
+ new PaperweightServerLevelDelegateProxy(editSession, serverLevel, adapter)
+ );
+ }
+
+ @Nullable
+ private BlockEntity getBlockEntity(BlockPos blockPos) {
+ BlockEntity tileEntity = this.serverLevel.getChunkAt(blockPos).getBlockEntity(blockPos);
+ if (tileEntity == null) {
+ return null;
+ }
+ BlockEntity newEntity = tileEntity.getType().create(blockPos, getBlockState(blockPos));
+ newEntity.loadWithComponents(
+ (CompoundTag) adapter.fromNative(this.editSession.getFullBlock(BlockVector3.at(blockPos.getX(), blockPos.getY(), blockPos.getZ())).getNbtReference().getValue()),
+ this.serverLevel.registryAccess()
+ );
+
+ return newEntity;
+ }
+
+ private BlockState getBlockState(BlockPos blockPos) {
+ return adapter.adapt(this.editSession.getBlock(BlockVector3.at(blockPos.getX(), blockPos.getY(), blockPos.getZ())));
+ }
+
+ private boolean setBlock(BlockPos blockPos, BlockState blockState) {
+ try {
+ return editSession.setBlock(BlockVector3.at(blockPos.getX(), blockPos.getY(), blockPos.getZ()), adapter.adapt(blockState));
+ } catch (MaxChangedBlocksException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private boolean removeBlock(BlockPos blockPos, boolean bl) {
+ try {
+ return editSession.setBlock(BlockVector3.at(blockPos.getX(), blockPos.getY(), blockPos.getZ()), BlockTypes.AIR.getDefaultState());
+ } catch (MaxChangedBlocksException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private boolean addEntity(Entity entity) {
+ Vec3 pos = entity.getPosition(0.0f);
+ Location location = new Location(BukkitAdapter.adapt(serverLevel.getWorld()), pos.x(), pos.y(), pos.z());
+
+ ResourceLocation id = serverLevel.registryAccess().registryOrThrow(Registries.ENTITY_TYPE).getKey(entity.getType());
+ CompoundTag tag = new CompoundTag();
+ entity.saveWithoutId(tag);
+ BaseEntity baseEntity = new BaseEntity(EntityTypes.get(id.toString()), LazyReference.from(() -> (LinCompoundTag) adapter.toNative(tag)));
+
+ return editSession.createEntity(location, baseEntity) != null;
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ switch (method.getName()) {
+ case "a_", "getBlockState", "addFreshEntityWithPassengers" -> {
+ if (args.length == 1 && args[0] instanceof BlockPos blockPos) {
+ // getBlockState
+ return getBlockState(blockPos);
+ } else if (args.length >= 1 && args[0] instanceof Entity entity) {
+ // addFreshEntityWithPassengers
+ return addEntity(entity);
+ }
+ }
+ case "c_", "getBlockEntity" -> {
+ if (args.length == 1 && args[0] instanceof BlockPos blockPos) {
+ // getBlockEntity
+ return getBlockEntity(blockPos);
+ }
+ }
+ case "a", "setBlock", "removeBlock", "destroyBlock" -> {
+ if (args.length >= 2 && args[0] instanceof BlockPos blockPos && args[1] instanceof BlockState blockState) {
+ // setBlock
+ return setBlock(blockPos, blockState);
+ } else if (args.length >= 2 && args[0] instanceof BlockPos blockPos && args[1] instanceof Boolean bl) {
+ // removeBlock (and also matches destroyBlock)
+ return removeBlock(blockPos, bl);
+ }
+ }
+ case "j", "addEntity", "addFreshEntity" -> {
+ if (args.length >= 1 && args[0] instanceof Entity entity) {
+ return addEntity(entity);
+ }
+ }
+ default -> { }
+ }
+
+ return method.invoke(this.serverLevel, args);
+ }
+
+}
diff --git a/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightWorldNativeAccess.java b/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightWorldNativeAccess.java
new file mode 100644
index 0000000000..33096e005d
--- /dev/null
+++ b/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightWorldNativeAccess.java
@@ -0,0 +1,186 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.bukkit.adapter.impl.v1_20_R4;
+
+import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
+import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
+import com.sk89q.worldedit.util.SideEffect;
+import com.sk89q.worldedit.util.SideEffectSet;
+import com.sk89q.worldedit.world.block.BlockState;
+import net.minecraft.core.BlockPos;
+import net.minecraft.nbt.Tag;
+import net.minecraft.server.level.FullChunkStatus;
+import net.minecraft.server.level.ServerLevel;
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.entity.BlockEntity;
+import net.minecraft.world.level.chunk.LevelChunk;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.block.data.CraftBlockData;
+import org.bukkit.event.block.BlockPhysicsEvent;
+import org.enginehub.linbus.tree.LinCompoundTag;
+
+import java.lang.ref.WeakReference;
+import java.util.Objects;
+import javax.annotation.Nullable;
+
+public class PaperweightWorldNativeAccess implements WorldNativeAccess {
+ private static final int UPDATE = 1;
+ private static final int NOTIFY = 2;
+
+ private final PaperweightAdapter adapter;
+ private final WeakReference world;
+ private SideEffectSet sideEffectSet;
+
+ public PaperweightWorldNativeAccess(PaperweightAdapter adapter, WeakReference world) {
+ this.adapter = adapter;
+ this.world = world;
+ }
+
+ private ServerLevel getWorld() {
+ return Objects.requireNonNull(world.get(), "The reference to the world was lost");
+ }
+
+ @Override
+ public void setCurrentSideEffectSet(SideEffectSet sideEffectSet) {
+ this.sideEffectSet = sideEffectSet;
+ }
+
+ @Override
+ public LevelChunk getChunk(int x, int z) {
+ return getWorld().getChunk(x, z);
+ }
+
+ @Override
+ public net.minecraft.world.level.block.state.BlockState toNative(BlockState state) {
+ int stateId = BlockStateIdAccess.getBlockStateId(state);
+ return BlockStateIdAccess.isValidInternalId(stateId)
+ ? Block.stateById(stateId)
+ : ((CraftBlockData) BukkitAdapter.adapt(state)).getState();
+ }
+
+ @Override
+ public net.minecraft.world.level.block.state.BlockState getBlockState(LevelChunk chunk, BlockPos position) {
+ return chunk.getBlockState(position);
+ }
+
+ @Nullable
+ @Override
+ public net.minecraft.world.level.block.state.BlockState setBlockState(LevelChunk chunk, BlockPos position, net.minecraft.world.level.block.state.BlockState state) {
+ return chunk.setBlockState(position, state, false, this.sideEffectSet.shouldApply(SideEffect.UPDATE));
+ }
+
+ @Override
+ public net.minecraft.world.level.block.state.BlockState getValidBlockForPosition(net.minecraft.world.level.block.state.BlockState block, BlockPos position) {
+ return Block.updateFromNeighbourShapes(block, getWorld(), position);
+ }
+
+ @Override
+ public BlockPos getPosition(int x, int y, int z) {
+ return new BlockPos(x, y, z);
+ }
+
+ @Override
+ public void updateLightingForBlock(BlockPos position) {
+ getWorld().getChunkSource().getLightEngine().checkBlock(position);
+ }
+
+ @Override
+ public boolean updateTileEntity(BlockPos position, LinCompoundTag tag) {
+ // We will assume that the tile entity was created for us
+ BlockEntity tileEntity = getWorld().getBlockEntity(position);
+ if (tileEntity == null) {
+ return false;
+ }
+ Tag nativeTag = adapter.fromNative(tag);
+ PaperweightAdapter.readTagIntoTileEntity((net.minecraft.nbt.CompoundTag) nativeTag, tileEntity);
+ return true;
+ }
+
+ @Override
+ public void notifyBlockUpdate(LevelChunk chunk, BlockPos position, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) {
+ if (chunk.getSections()[getWorld().getSectionIndex(position.getY())] != null) {
+ getWorld().sendBlockUpdated(position, oldState, newState, UPDATE | NOTIFY);
+ }
+ }
+
+ @Override
+ public boolean isChunkTicking(LevelChunk chunk) {
+ return chunk.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING);
+ }
+
+ @Override
+ public void markBlockChanged(LevelChunk chunk, BlockPos position) {
+ if (chunk.getSections()[getWorld().getSectionIndex(position.getY())] != null) {
+ getWorld().getChunkSource().blockChanged(position);
+ }
+ }
+
+ @Override
+ public void notifyNeighbors(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) {
+ ServerLevel world = getWorld();
+ if (sideEffectSet.shouldApply(SideEffect.EVENTS)) {
+ world.updateNeighborsAt(pos, oldState.getBlock());
+ } else {
+ // When we don't want events, manually run the physics without them.
+ Block block = oldState.getBlock();
+ fireNeighborChanged(pos, world, block, pos.west());
+ fireNeighborChanged(pos, world, block, pos.east());
+ fireNeighborChanged(pos, world, block, pos.below());
+ fireNeighborChanged(pos, world, block, pos.above());
+ fireNeighborChanged(pos, world, block, pos.north());
+ fireNeighborChanged(pos, world, block, pos.south());
+ }
+ if (newState.hasAnalogOutputSignal()) {
+ world.updateNeighbourForOutputSignal(pos, newState.getBlock());
+ }
+ }
+
+ @Override
+ public void updateBlock(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) {
+ ServerLevel world = getWorld();
+ newState.onPlace(world, pos, oldState, false);
+ }
+
+ private void fireNeighborChanged(BlockPos pos, ServerLevel world, Block block, BlockPos neighborPos) {
+ world.getBlockState(neighborPos).handleNeighborChanged(world, neighborPos, block, pos, false);
+ }
+
+ @Override
+ public void updateNeighbors(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState, int recursionLimit) {
+ ServerLevel world = getWorld();
+ oldState.updateIndirectNeighbourShapes(world, pos, NOTIFY, recursionLimit);
+ if (sideEffectSet.shouldApply(SideEffect.EVENTS)) {
+ CraftWorld craftWorld = world.getWorld();
+ BlockPhysicsEvent event = new BlockPhysicsEvent(craftWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), CraftBlockData.fromData(newState));
+ world.getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ }
+ newState.updateNeighbourShapes(world, pos, NOTIFY, recursionLimit);
+ newState.updateIndirectNeighbourShapes(world, pos, NOTIFY, recursionLimit);
+ }
+
+ @Override
+ public void onBlockStateChange(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) {
+ getWorld().onBlockStateChange(pos, oldState, newState);
+ }
+}
From 53b182fecf53e7ca0c18004fd0e8d854e871feae Mon Sep 17 00:00:00 2001
From: Madeline Miller
Date: Sun, 28 Apr 2024 14:27:03 +1000
Subject: [PATCH 13/21] Update for NeoForge tick event refactor
---
worldedit-neoforge/build.gradle.kts | 2 +-
.../com/sk89q/worldedit/neoforge/ThreadSafeCache.java | 8 ++------
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/worldedit-neoforge/build.gradle.kts b/worldedit-neoforge/build.gradle.kts
index 8b3b1f76eb..4460a66889 100644
--- a/worldedit-neoforge/build.gradle.kts
+++ b/worldedit-neoforge/build.gradle.kts
@@ -13,7 +13,7 @@ val minecraftVersion = "1.20.5"
val nextMajorMinecraftVersion: String = minecraftVersion.split('.').let { (useless, major) ->
"$useless.${major.toInt() + 1}"
}
-val neoVersion = "20.5.0-beta"
+val neoVersion = "20.5.16-beta"
val apiClasspath = configurations.create("apiClasspath") {
isCanBeResolved = true
diff --git a/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/ThreadSafeCache.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/ThreadSafeCache.java
index 9fae482670..a61c281a33 100644
--- a/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/ThreadSafeCache.java
+++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/ThreadSafeCache.java
@@ -22,7 +22,7 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.neoforged.bus.api.SubscribeEvent;
-import net.neoforged.neoforge.event.TickEvent;
+import net.neoforged.neoforge.event.tick.ServerTickEvent;
import net.neoforged.neoforge.server.ServerLifecycleHooks;
import java.util.Collections;
@@ -51,11 +51,7 @@ public Set getOnlineIds() {
}
@SubscribeEvent
- public void tickStart(TickEvent.ServerTickEvent event) {
- if (event.phase != TickEvent.Phase.END) {
- return;
- }
-
+ public void onEndTick(ServerTickEvent.Post event) {
long now = System.currentTimeMillis();
if (now - lastRefresh > REFRESH_DELAY) {
From e5fe510126e5ff261faf459ffdee7eef56941455 Mon Sep 17 00:00:00 2001
From: Octavia Togami
Date: Sun, 28 Apr 2024 18:00:33 -0700
Subject: [PATCH 14/21] Clean up leftover Forge verification
---
verification/build.gradle.kts | 5 -----
1 file changed, 5 deletions(-)
diff --git a/verification/build.gradle.kts b/verification/build.gradle.kts
index 54872941cc..0024ee1b16 100644
--- a/verification/build.gradle.kts
+++ b/verification/build.gradle.kts
@@ -134,8 +134,3 @@ tasks.named("checkFabricApiCompatibility") {
// Need to check against the reobf JAR
newClasspath.setFrom(project(":worldedit-fabric").tasks.named("remapJar"))
}
-//tasks.named("checkForgeApiCompatibility") {
-// // Need to check against the reobf JAR
-// newClasspath.builtBy(project(":worldedit-neoforge").tasks.named("reobfJar"))
-//}
-""
From b6aabb03fbbd265ff51b4b2289015a2aa35e9b64 Mon Sep 17 00:00:00 2001
From: Madeline Miller
Date: Tue, 30 Apr 2024 22:13:01 +1000
Subject: [PATCH 15/21] [Bukkit] Allow loading on 1.20.6
---
.../bukkit/adapter/impl/v1_20_R4/PaperweightAdapter.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightAdapter.java
index c20b5a9749..ca3ec0d9b2 100644
--- a/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightAdapter.java
+++ b/worldedit-bukkit/adapters/adapter-1.20.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_20_R4/PaperweightAdapter.java
@@ -217,8 +217,8 @@ public PaperweightAdapter() throws NoSuchFieldException, NoSuchMethodException {
CraftServer.class.cast(Bukkit.getServer());
int dataVersion = CraftMagicNumbers.INSTANCE.getDataVersion();
- if (dataVersion != 3837) {
- throw new UnsupportedClassVersionError("Not 1.20.5!");
+ if (dataVersion != 3837 && dataVersion != 3839) {
+ throw new UnsupportedClassVersionError("Not 1.20.(5/6)!");
}
serverWorldsField = CraftServer.class.getDeclaredField("worlds");
From 4a48dcb3940415e5a04ed0f4f95207ca492270ca Mon Sep 17 00:00:00 2001
From: Octavia Togami
Date: Mon, 29 Apr 2024 01:23:07 -0700
Subject: [PATCH 16/21] Move all versions to version catalogs
---
build.gradle.kts | 2 +-
buildSrc/build.gradle.kts | 42 ++----
buildSrc/settings.gradle.kts | 9 ++
buildSrc/src/main/kotlin/AdapterConfig.kt | 2 +-
buildSrc/src/main/kotlin/CommonConfig.kt | 37 ++---
buildSrc/src/main/kotlin/CommonJavaConfig.kt | 14 +-
buildSrc/src/main/kotlin/GradleExtras.kt | 16 ++
buildSrc/src/main/kotlin/LibsConfig.kt | 18 ++-
buildSrc/src/main/kotlin/Versions.kt | 24 ---
gradle.properties | 3 -
gradle/libs.versions.toml | 149 +++++++++++++++++++
worldedit-bukkit/build.gradle.kts | 26 ++--
worldedit-cli/build.gradle.kts | 16 +-
worldedit-core/build.gradle.kts | 58 ++++----
worldedit-core/doctools/build.gradle.kts | 2 +-
worldedit-fabric/build.gradle.kts | 23 ++-
worldedit-libs/bukkit/build.gradle.kts | 2 +-
worldedit-libs/core/ap/build.gradle.kts | 4 +-
worldedit-libs/core/build.gradle.kts | 23 +--
worldedit-neoforge/build.gradle.kts | 15 +-
worldedit-sponge/build.gradle.kts | 4 -
21 files changed, 309 insertions(+), 180 deletions(-)
create mode 100644 buildSrc/settings.gradle.kts
delete mode 100644 buildSrc/src/main/kotlin/Versions.kt
create mode 100644 gradle/libs.versions.toml
diff --git a/build.gradle.kts b/build.gradle.kts
index f273c9701e..939ab60971 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -10,7 +10,7 @@ buildscript {
}
}
dependencies {
- classpath("net.fabricmc:fabric-loom:${versions.loom}")
+ classpath(libs.fabric.loom)
}
}
plugins {
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
index 3b4300289d..f277a4f592 100644
--- a/buildSrc/build.gradle.kts
+++ b/buildSrc/build.gradle.kts
@@ -1,5 +1,3 @@
-import java.util.Properties
-
plugins {
`kotlin-dsl`
}
@@ -25,49 +23,33 @@ repositories {
name = "Fabric"
url = uri("https://maven.fabricmc.net/")
}
- maven {
- name = "sponge"
- url = uri("https://repo.spongepowered.org/maven")
- }
maven {
name = "EngineHub Repository"
url = uri("https://maven.enginehub.org/repo/")
}
}
-val properties = Properties().also { props ->
- project.projectDir.resolveSibling("gradle.properties").bufferedReader().use {
- props.load(it)
- }
-}
-val loomVersion: String = properties.getProperty("loom.version")
-val mixinVersion: String = properties.getProperty("mixin.version")
-
dependencies {
implementation(gradleApi())
- implementation("gradle.plugin.org.cadixdev.gradle:licenser:0.6.1")
- implementation("org.ajoberstar.grgit:grgit-gradle:5.2.2")
- implementation("me.champeau.gradle:japicmp-gradle-plugin:0.4.2")
- implementation("com.github.johnrengelman:shadow:8.1.1")
- implementation("org.jfrog.buildinfo:build-info-extractor-gradle:5.2.0")
- implementation("org.spongepowered:spongegradle-plugin-development:2.2.0")
- implementation("org.spongepowered:vanillagradle:0.2.1-20231105.223944-69")
- val neoGradleVersion = "7.0.107"
- implementation("net.neoforged.gradle:userdev:$neoGradleVersion")
- implementation("net.neoforged.gradle:mixin:$neoGradleVersion")
- implementation("net.fabricmc:fabric-loom:$loomVersion")
- implementation("net.fabricmc:sponge-mixin:$mixinVersion")
- implementation("org.enginehub.gradle:gradle-codecov-plugin:0.2.0")
- implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.6.0")
+ implementation(libs.licenser)
+ implementation(libs.grgit)
+ implementation(libs.japicmp)
+ implementation(libs.shadow)
+ implementation(libs.jfrog.buildinfo)
+ implementation(libs.neoGradle.userdev)
+ implementation(libs.fabric.loom)
+ implementation(libs.fabric.mixin)
+ implementation(libs.codecov)
+ implementation(libs.paperweight)
constraints {
- val asmVersion = "[9.7,)"
+ val asmVersion = "[${libs.versions.minimumAsm.get()},)"
implementation("org.ow2.asm:asm:$asmVersion") {
because("Need Java 21 support in shadow")
}
implementation("org.ow2.asm:asm-commons:$asmVersion") {
because("Need Java 21 support in shadow")
}
- implementation("org.vafer:jdependency:[2.10,)") {
+ implementation("org.vafer:jdependency:[${libs.versions.minimumJdependency.get()},)") {
because("Need Java 21 support in shadow")
}
}
diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts
new file mode 100644
index 0000000000..aa5e146f1c
--- /dev/null
+++ b/buildSrc/settings.gradle.kts
@@ -0,0 +1,9 @@
+dependencyResolutionManagement {
+ versionCatalogs {
+ create("libs") {
+ from(files("../gradle/libs.versions.toml"))
+ }
+ }
+}
+
+rootProject.name = "build-logic"
diff --git a/buildSrc/src/main/kotlin/AdapterConfig.kt b/buildSrc/src/main/kotlin/AdapterConfig.kt
index c940cb51d4..240a623d29 100644
--- a/buildSrc/src/main/kotlin/AdapterConfig.kt
+++ b/buildSrc/src/main/kotlin/AdapterConfig.kt
@@ -17,7 +17,7 @@ fun Project.applyPaperweightAdapterConfiguration(javaRelease: Int = 21) {
dependencies {
"implementation"(project(":worldedit-bukkit"))
constraints {
- "remapper"("net.fabricmc:tiny-remapper:[0.8.11,)") {
+ "remapper"("net.fabricmc:tiny-remapper:[${stringyLibs.getVersion("minimumTinyRemapper")},)") {
because("Need remapper to support Java 21")
}
}
diff --git a/buildSrc/src/main/kotlin/CommonConfig.kt b/buildSrc/src/main/kotlin/CommonConfig.kt
index 6f3faa8018..176ac48389 100644
--- a/buildSrc/src/main/kotlin/CommonConfig.kt
+++ b/buildSrc/src/main/kotlin/CommonConfig.kt
@@ -1,13 +1,13 @@
+import groovy.lang.Closure
import org.cadixdev.gradle.licenser.LicenseExtension
import org.gradle.api.Project
+import org.gradle.api.artifacts.Dependency
+import org.gradle.api.artifacts.ExternalModuleDependency
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.jvm.toolchain.JavaLanguageVersion
-import org.gradle.kotlin.dsl.apply
-import org.gradle.kotlin.dsl.configure
-import org.gradle.kotlin.dsl.dependencies
-import org.gradle.kotlin.dsl.repositories
-import org.gradle.kotlin.dsl.the
+import org.gradle.kotlin.dsl.*
import org.gradle.plugins.ide.idea.model.IdeaModel
+import java.util.concurrent.TimeUnit
fun Project.applyCommonConfiguration() {
group = rootProject.group
@@ -30,7 +30,7 @@ fun Project.applyCommonConfiguration() {
configurations.all {
resolutionStrategy {
- cacheChangingModulesFor(5, "MINUTES")
+ cacheChangingModulesFor(1, TimeUnit.DAYS)
}
}
@@ -41,22 +41,23 @@ fun Project.applyCommonConfiguration() {
}
dependencies {
- constraints {
- for (conf in configurations) {
- if (conf.isCanBeConsumed || conf.isCanBeResolved) {
- // dependencies don't get declared in these
- continue
- }
- add(conf.name, "com.google.guava:guava") {
- version { require(Versions.GUAVA) }
+ for (conf in listOf("implementation", "api")) {
+ if (!configurations.names.contains(conf)) {
+ continue
+ }
+ add(conf, enforcedPlatform(stringyLibs.getLibrary("log4j-bom")).map {
+ val dep = create(it)
+ dep.because("Mojang provides Log4j")
+ dep
+ })
+ constraints {
+ add(conf, stringyLibs.getLibrary("guava")) {
because("Mojang provides Guava")
}
- add(conf.name, "com.google.code.gson:gson") {
- version { require(Versions.GSON) }
+ add(conf, stringyLibs.getLibrary("gson")) {
because("Mojang provides Gson")
}
- add(conf.name, "it.unimi.dsi:fastutil") {
- version { require(Versions.FAST_UTIL) }
+ add(conf, stringyLibs.getLibrary("fastutil")) {
because("Mojang provides FastUtil")
}
}
diff --git a/buildSrc/src/main/kotlin/CommonJavaConfig.kt b/buildSrc/src/main/kotlin/CommonJavaConfig.kt
index 5df3fb4f20..3c58b86ead 100644
--- a/buildSrc/src/main/kotlin/CommonJavaConfig.kt
+++ b/buildSrc/src/main/kotlin/CommonJavaConfig.kt
@@ -43,12 +43,14 @@ fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, javaRelease: Int =
}
dependencies {
- "compileOnly"("com.google.code.findbugs:jsr305:3.0.2")
- "testImplementation"("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}")
- "testImplementation"("org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT}")
- "testImplementation"("org.mockito:mockito-core:${Versions.MOCKITO}")
- "testImplementation"("org.mockito:mockito-junit-jupiter:${Versions.MOCKITO}")
- "testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT}")
+ "compileOnly"(stringyLibs.getLibrary("jsr305"))
+ "testImplementation"(platform(stringyLibs.getLibrary("junit-bom")))
+ "testImplementation"(stringyLibs.getLibrary("junit-jupiter-api"))
+ "testImplementation"(stringyLibs.getLibrary("junit-jupiter-params"))
+ "testImplementation"(platform(stringyLibs.getLibrary("mockito-bom")))
+ "testImplementation"(stringyLibs.getLibrary("mockito-core"))
+ "testImplementation"(stringyLibs.getLibrary("mockito-junit-jupiter"))
+ "testRuntimeOnly"(stringyLibs.getLibrary("junit-jupiter-engine"))
}
// Java 8 turns on doclint which we fail
diff --git a/buildSrc/src/main/kotlin/GradleExtras.kt b/buildSrc/src/main/kotlin/GradleExtras.kt
index beedf16078..e6d1fa3c66 100644
--- a/buildSrc/src/main/kotlin/GradleExtras.kt
+++ b/buildSrc/src/main/kotlin/GradleExtras.kt
@@ -1,6 +1,11 @@
import org.gradle.api.Project
+import org.gradle.api.artifacts.MinimalExternalModuleDependency
+import org.gradle.api.artifacts.VersionCatalog
+import org.gradle.api.artifacts.VersionCatalogsExtension
+import org.gradle.api.artifacts.VersionConstraint
import org.gradle.api.plugins.ExtraPropertiesExtension
import org.gradle.api.plugins.JavaPluginExtension
+import org.gradle.api.provider.Provider
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.the
@@ -10,3 +15,14 @@ val Project.ext: ExtraPropertiesExtension
val Project.sourceSets: SourceSetContainer
get() = the().sourceSets
+
+val Project.stringyLibs: VersionCatalog
+ get() = extensions.getByType().named("libs")
+
+fun VersionCatalog.getLibrary(name: String): Provider = findLibrary(name).orElseThrow {
+ error("Library $name not found in version catalog")
+}
+
+fun VersionCatalog.getVersion(name: String): VersionConstraint = findVersion(name).orElseThrow {
+ error("Version $name not found in version catalog")
+}
diff --git a/buildSrc/src/main/kotlin/LibsConfig.kt b/buildSrc/src/main/kotlin/LibsConfig.kt
index 9c112d3a47..90caecaba8 100644
--- a/buildSrc/src/main/kotlin/LibsConfig.kt
+++ b/buildSrc/src/main/kotlin/LibsConfig.kt
@@ -71,11 +71,19 @@ fun Project.applyLibrariesConfiguration() {
.filterIsInstance()
.map { it.copy() }
.map { dependency ->
- dependency.artifact {
- name = dependency.name
- type = artifactType
- extension = "jar"
- classifier = artifactType
+ val category = dependency.attributes.getAttribute(Category.CATEGORY_ATTRIBUTE)?.name
+ if (category == Category.REGULAR_PLATFORM || category == Category.ENFORCED_PLATFORM) {
+ return@map dependency
+ }
+ try {
+ dependency.artifact {
+ name = dependency.name
+ type = artifactType
+ extension = "jar"
+ classifier = artifactType
+ }
+ } catch (e: Exception) {
+ throw RuntimeException("Failed to add artifact to dependency: $dependency", e)
}
dependency
}
diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt
deleted file mode 100644
index c17780708c..0000000000
--- a/buildSrc/src/main/kotlin/Versions.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-import org.gradle.api.Project
-
-object Versions {
- const val TEXT = "3.0.4"
- const val TEXT_EXTRAS = "3.0.6"
- const val PISTON = "0.5.10"
- const val AUTO_VALUE = "1.10.4"
- const val JUNIT = "5.10.2"
- const val MOCKITO = "5.11.0"
- const val FAST_UTIL = "8.5.12"
- const val GUAVA = "32.1.3-jre"
- const val GSON = "2.10.1"
- const val LOG4J = "2.22.1"
- const val LIN_BUS = "0.1.0-SNAPSHOT"
-}
-
-// Properties that need a project reference to resolve:
-class ProjectVersions(project: Project) {
- val loom = project.rootProject.property("loom.version")
- val mixin = project.rootProject.property("mixin.version")
-}
-
-val Project.versions
- get() = ProjectVersions(this)
diff --git a/gradle.properties b/gradle.properties
index d0ac11716d..b0002ffc26 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,6 +3,3 @@ version=7.3.1-SNAPSHOT
org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true
-
-loom.version=1.6.9
-mixin.version=0.13.3+mixin.0.8.5
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
new file mode 100644
index 0000000000..d5400084c6
--- /dev/null
+++ b/gradle/libs.versions.toml
@@ -0,0 +1,149 @@
+[versions]
+neoGradle = "7.0.107"
+
+kyoriText = "3.0.4"
+piston = "0.5.10"
+autoValue = "1.10.4"
+antlr = "4.13.1"
+
+fabric-api = "0.97.6+1.20.5"
+
+neoforge-minecraft = "1.20.5"
+
+# https://parchmentmc.org/docs/getting-started; note that we use older MC versions some times which is OK
+parchment-minecraft = "1.20.4"
+parchment-mappings = "2024.04.14"
+
+# Minimum versions we apply to make dependencies support newer Java
+minimumAsm = "9.7"
+minimumJdependency = "2.10"
+minimumTinyRemapper = "0.8.11"
+
+lang-worldeditBase = "7.3.1"
+lang-version = "1309"
+
+[libraries]
+licenser = "gradle.plugin.org.cadixdev.gradle:licenser:0.6.1"
+grgit = "org.ajoberstar.grgit:grgit-gradle:5.2.2"
+japicmp = "me.champeau.gradle:japicmp-gradle-plugin:0.4.2"
+shadow = "com.github.johnrengelman:shadow:8.1.1"
+jfrog-buildinfo = "org.jfrog.buildinfo:build-info-extractor-gradle:5.2.0"
+
+fabric-loom = "net.fabricmc:fabric-loom:1.6.9"
+fabric-mixin = "net.fabricmc:sponge-mixin:0.13.3+mixin.0.8.5"
+
+codecov = "org.enginehub.gradle:gradle-codecov-plugin:0.2.0"
+paperweight = "io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.6.0"
+
+linBus-bom = "org.enginehub.lin-bus:lin-bus-bom:0.1.0-SNAPSHOT"
+linBus-common.module = "org.enginehub.lin-bus:lin-bus-common"
+linBus-stream.module = "org.enginehub.lin-bus:lin-bus-stream"
+linBus-tree.module = "org.enginehub.lin-bus:lin-bus-tree"
+linBus-format-snbt.module = "org.enginehub.lin-bus.format:lin-bus-format-snbt"
+
+autoService = "com.google.auto.service:auto-service:1.1.1"
+
+jsr305 = "com.google.code.findbugs:jsr305:3.0.2"
+jetbrains-annotations = "org.jetbrains:annotations:24.1.0"
+errorprone-annotations = "com.google.errorprone:error_prone_annotations:2.11.0"
+
+junit-bom = "org.junit:junit-bom:5.10.2"
+junit-jupiter-api.module = "org.junit.jupiter:junit-jupiter-api"
+junit-jupiter-params.module = "org.junit.jupiter:junit-jupiter-params"
+junit-jupiter-engine.module = "org.junit.jupiter:junit-jupiter-engine"
+
+mockito-bom = "org.mockito:mockito-bom:5.11.0"
+mockito-core.module = "org.mockito:mockito-core"
+mockito-junit-jupiter.module = "org.mockito:mockito-junit-jupiter"
+
+commonsCli = "commons-cli:commons-cli:1.4"
+
+spigot = "org.spigotmc:spigot-api:1.20.1-R0.1-20230921.163938-66"
+paperApi = "io.papermc.paper:paper-api:1.20.1-R0.1-20230921.165944-178"
+paperLib = "io.papermc:paperlib:1.0.7"
+
+dummypermscompat = "com.sk89q:dummypermscompat:1.10"
+bstats-bukkit = "org.bstats:bstats-bukkit:2.2.1"
+
+trueZip = "de.schlichtherle:truezip:6.8.4"
+rhino = "org.mozilla:rhino-runtime:1.7.13"
+jchronic = "com.sk89q:jchronic:0.2.4a"
+jlibnoise = "com.sk89q.lib:jlibnoise:1.0.0"
+
+fabric-minecraft = "com.mojang:minecraft:1.20.5"
+fabric-loader = "net.fabricmc:fabric-loader:0.15.10"
+fabric-permissions-api = "me.lucko:fabric-permissions-api:0.1-SNAPSHOT"
+
+neoforge = "net.neoforged:neoforge:20.5.16-beta"
+
+# Mojang-provided libraries, CHECK AGAINST MINECRAFT for versions
+guava = "com.google.guava:guava:32.1.3-jre!!"
+log4j-bom = "org.apache.logging.log4j:log4j-bom:2.22.1!!"
+log4j-api.module = "org.apache.logging.log4j:log4j-api"
+log4j-core.module = "org.apache.logging.log4j:log4j-core"
+gson = "com.google.code.gson:gson:2.10.1!!"
+fastutil = "it.unimi.dsi:fastutil:8.5.12!!"
+
+# Bukkit-provided libraries, CHECK AGAINST SPIGOT for versions
+# Note that we need to balance support for older MC versus working at all on newer ones, so the exact versions here
+# may not be the same as the ones in the latest Bukkit API.
+snakeyaml = "org.yaml:snakeyaml:2.0"
+
+[libraries.neoGradle-userdev]
+module = "net.neoforged.gradle:userdev"
+version.ref = "neoGradle"
+
+[libraries.kyoriText-api]
+module = "net.kyori:text-api"
+version.ref = "kyoriText"
+
+[libraries.kyoriText-serializer-gson]
+module = "net.kyori:text-serializer-gson"
+version.ref = "kyoriText"
+
+[libraries.kyoriText-serializer-legacy]
+module = "net.kyori:text-serializer-legacy"
+version.ref = "kyoriText"
+
+[libraries.kyoriText-serializer-plain]
+module = "net.kyori:text-serializer-plain"
+version.ref = "kyoriText"
+
+[libraries.kyoriText-adapter-bukkit]
+module = "net.kyori:text-adapter-bukkit"
+version = "3.0.6"
+
+[libraries.piston-core]
+module = "org.enginehub.piston:core"
+version.ref = "piston"
+
+[libraries.piston-defaultImpl]
+module = "org.enginehub.piston:default-impl"
+version.ref = "piston"
+
+[libraries.piston-coreAp-annotations]
+module = "org.enginehub.piston.core-ap:annotations"
+version.ref = "piston"
+
+[libraries.piston-coreAp-processor]
+module = "org.enginehub.piston.core-ap:processor"
+version.ref = "piston"
+
+[libraries.piston-coreAp-runtime]
+module = "org.enginehub.piston.core-ap:runtime"
+version.ref = "piston"
+
+[libraries.autoValue]
+module = "com.google.auto.value:auto-value"
+version.ref = "autoValue"
+
+[libraries.autoValue-annotations]
+module = "com.google.auto.value:auto-value-annotations"
+version.ref = "autoValue"
+
+[libraries.antlr4]
+module = "org.antlr:antlr4"
+version.ref = "antlr"
+
+[libraries.antlr4-runtime]
+module = "org.antlr:antlr4-runtime"
diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts
index 9f8a9dc15a..b2ac1b362f 100644
--- a/worldedit-bukkit/build.gradle.kts
+++ b/worldedit-bukkit/build.gradle.kts
@@ -42,25 +42,29 @@ dependencies {
"api"(project(":worldedit-libs:bukkit"))
// Technically this is api, but everyone should already have some form of the bukkit API
// Avoid pulling in another one, especially one so outdated.
- "localImplementation"("org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT") {
+ "localImplementation"(libs.spigot) {
exclude("junit", "junit")
}
- "localImplementation"(platform("org.apache.logging.log4j:log4j-bom:${Versions.LOG4J}") {
+ "localImplementation"(platform(libs.log4j.bom)) {
because("Spigot provides Log4J (sort of, not in API, implicitly part of server)")
- })
- "localImplementation"("org.apache.logging.log4j:log4j-api")
+ }
+ "localImplementation"(libs.log4j.api)
- "compileOnly"("org.jetbrains:annotations:20.1.0")
- "compileOnly"("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") {
+ "compileOnly"(libs.jetbrains.annotations) {
+ because("Resolving Spigot annotations")
+ }
+ "testCompileOnly"(libs.jetbrains.annotations) {
+ because("Resolving Spigot annotations")
+ }
+ "compileOnly"(libs.paperApi) {
exclude("org.slf4j", "slf4j-api")
exclude("junit", "junit")
}
- "implementation"("io.papermc:paperlib:1.0.7")
- "compileOnly"("com.sk89q:dummypermscompat:1.10")
- "implementation"("org.bstats:bstats-bukkit:2.2.1")
- "implementation"("it.unimi.dsi:fastutil")
- "testImplementation"("org.mockito:mockito-core:1.9.0-rc1")
+ "implementation"(libs.paperLib)
+ "compileOnly"(libs.dummypermscompat)
+ "implementation"(libs.bstats.bukkit)
+ "implementation"(libs.fastutil)
project.project(":worldedit-bukkit:adapters").subprojects.forEach {
"adapters"(project(it.path))
diff --git a/worldedit-cli/build.gradle.kts b/worldedit-cli/build.gradle.kts
index 718bc608aa..d830726ba9 100644
--- a/worldedit-cli/build.gradle.kts
+++ b/worldedit-cli/build.gradle.kts
@@ -17,16 +17,14 @@ addJarManifest(
dependencies {
"compileOnly"(project(":worldedit-libs:core:ap"))
"annotationProcessor"(project(":worldedit-libs:core:ap"))
- "annotationProcessor"("com.google.guava:guava:${Versions.GUAVA}")
+ "annotationProcessor"(libs.guava)
"api"(project(":worldedit-core"))
- "implementation"(platform("org.apache.logging.log4j:log4j-bom:${Versions.LOG4J}") {
- because("We control Log4J on this platform")
- })
- "implementation"("org.apache.logging.log4j:log4j-api")
- "implementation"("org.apache.logging.log4j:log4j-core")
- "implementation"("commons-cli:commons-cli:1.4")
- "implementation"("com.google.guava:guava")
- "implementation"("com.google.code.gson:gson")
+ "implementation"(platform(libs.log4j.bom))
+ "implementation"(libs.log4j.api)
+ "implementation"(libs.log4j.core)
+ "implementation"(libs.commonsCli)
+ "implementation"(libs.guava)
+ "implementation"(libs.gson)
}
tasks.named("shadowJar") {
diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts
index 96f859cba5..4d03138672 100644
--- a/worldedit-core/build.gradle.kts
+++ b/worldedit-core/build.gradle.kts
@@ -28,53 +28,53 @@ configurations {
dependencies {
constraints {
- "implementation"( "org.yaml:snakeyaml") {
- version { require("2.0") }
+ "implementation"(libs.snakeyaml) {
because("Bukkit provides SnakeYaml")
}
}
"api"(project(":worldedit-libs:core"))
- "compileOnly"("de.schlichtherle:truezip:6.8.4")
- "implementation"("org.mozilla:rhino-runtime:1.7.13")
- "implementation"("org.yaml:snakeyaml:2.0")
- "implementation"("com.google.guava:guava")
- "compileOnlyApi"("com.google.code.findbugs:jsr305:1.3.9")
- "implementation"("com.google.code.gson:gson")
-
- "implementation"("com.sk89q:jchronic:0.2.4a") {
+ "compileOnly"(libs.trueZip)
+ "implementation"(libs.rhino)
+ "implementation"(libs.snakeyaml)
+ "implementation"(libs.guava)
+ "compileOnlyApi"(libs.jsr305)
+ "implementation"(libs.gson)
+
+ "implementation"(libs.jchronic) {
exclude(group = "junit", module = "junit")
}
- "implementation"("com.thoughtworks.paranamer:paranamer:2.6")
- "implementation"("com.sk89q.lib:jlibnoise:1.0.0")
- "api"(platform("org.enginehub.lin-bus:lin-bus-bom:${Versions.LIN_BUS}"))
- "api"("org.enginehub.lin-bus:lin-bus-tree")
- "api"("org.enginehub.lin-bus.format:lin-bus-format-snbt")
-
- "implementation"("org.apache.logging.log4j:log4j-api:${Versions.LOG4J}") {
- because("Mojang provides Log4J")
- }
+ "implementation"(libs.jlibnoise)
+
+ "implementation"(libs.log4j.api)
- "implementation"("it.unimi.dsi:fastutil")
+ "implementation"(libs.fastutil)
- val antlrVersion = "4.13.1"
- "antlr"("org.antlr:antlr4:$antlrVersion")
- "implementation"("org.antlr:antlr4-runtime:$antlrVersion")
+ "antlr"(libs.antlr4)
+ "implementation"(libs.antlr4.runtime)
"compileOnly"(project(":worldedit-libs:core:ap"))
"annotationProcessor"(project(":worldedit-libs:core:ap"))
// ensure this is on the classpath for the AP
- "annotationProcessor"("com.google.guava:guava:${Versions.GUAVA}")
- "compileOnly"("com.google.auto.value:auto-value-annotations:${Versions.AUTO_VALUE}")
- "annotationProcessor"("com.google.auto.value:auto-value:${Versions.AUTO_VALUE}")
+ "annotationProcessor"(libs.guava)
+ "compileOnly"(libs.autoValue.annotations)
+ "annotationProcessor"(libs.autoValue)
- "compileOnly"("com.google.auto.service:auto-service:1.1.1") {
+ "compileOnly"(libs.autoService) {
because("Needed to resolve annotations in Piston")
}
+ "compileOnly"(libs.jetbrains.annotations) {
+ because("Needed to resolve annotations in lin-bus")
+ }
+ "testCompileOnly"(libs.jetbrains.annotations) {
+ because("Needed to resolve annotations in lin-bus")
+ }
- "languageFiles"("${project.group}:worldedit-lang:7.3.1:1309@zip")
+ "languageFiles"(
+ "${project.group}:worldedit-lang:${libs.versions.lang.worldeditBase.get()}:${libs.versions.lang.version.get()}@zip"
+ )
- "testRuntimeOnly"("org.apache.logging.log4j:log4j-core:${Versions.LOG4J}")
+ "testRuntimeOnly"(libs.log4j.core)
}
tasks.test {
diff --git a/worldedit-core/doctools/build.gradle.kts b/worldedit-core/doctools/build.gradle.kts
index f51cc415ea..b921ebc72f 100644
--- a/worldedit-core/doctools/build.gradle.kts
+++ b/worldedit-core/doctools/build.gradle.kts
@@ -15,5 +15,5 @@ dependencies {
"implementation"(project(":worldedit-core"))
"implementation"(kotlin("stdlib-jdk8"))
"implementation"(kotlin("reflect"))
- "implementation"("com.google.guava:guava")
+ "implementation"(libs.guava)
}
diff --git a/worldedit-fabric/build.gradle.kts b/worldedit-fabric/build.gradle.kts
index d472aa9e28..28c1dbc83a 100644
--- a/worldedit-fabric/build.gradle.kts
+++ b/worldedit-fabric/build.gradle.kts
@@ -12,8 +12,6 @@ plugins {
applyPlatformAndCoreConfiguration()
applyShadowConfiguration()
-val minecraftVersion = "1.20.5"
-
val fabricApiConfiguration: Configuration = configurations.create("fabricApi")
configure {
@@ -38,13 +36,10 @@ repositories {
dependencies {
"api"(project(":worldedit-core"))
- "implementation"(platform("org.apache.logging.log4j:log4j-bom:${Versions.LOG4J}") {
- because("Mojang provides Log4J")
- })
- "minecraft"("com.mojang:minecraft:$minecraftVersion")
+ "minecraft"(libs.fabric.minecraft)
"mappings"(project.the().officialMojangMappings())
- "modImplementation"("net.fabricmc:fabric-loader:0.15.10")
+ "modImplementation"(libs.fabric.loader)
// [1] Load the API dependencies from the fabric mod json...
@@ -57,25 +52,25 @@ dependencies {
.toSet()
// [2] Request the matching dependency from fabric-loom
for (wantedDependency in wantedDependencies) {
- val dep = project.the().module(wantedDependency, "0.97.6+1.20.5")
+ val dep = project.the().module(wantedDependency, libs.versions.fabric.api.get())
"include"(dep)
"modImplementation"(dep)
}
// No need for this at runtime
- "modCompileOnly"("me.lucko:fabric-permissions-api:0.1-SNAPSHOT")
+ "modCompileOnly"(libs.fabric.permissions.api)
// Hook these up manually, because Fabric doesn't seem to quite do it properly.
- "compileOnly"("net.fabricmc:sponge-mixin:${project.versions.mixin}")
- "annotationProcessor"("net.fabricmc:sponge-mixin:${project.versions.mixin}")
- "annotationProcessor"("net.fabricmc:fabric-loom:${project.versions.loom}")
+ "compileOnly"(libs.fabric.mixin)
+ "annotationProcessor"(libs.fabric.mixin)
+ "annotationProcessor"(libs.fabric.loom)
// Silence some warnings, since apparently this isn't on the compile classpath like it should be.
- "compileOnly"("com.google.errorprone:error_prone_annotations:2.11.0")
+ "compileOnly"(libs.errorprone.annotations)
}
configure {
- archivesName.set("${project.name}-mc$minecraftVersion")
+ archivesName.set("${project.name}-mc${libs.fabric.minecraft.get().version}")
}
configure {
diff --git a/worldedit-libs/bukkit/build.gradle.kts b/worldedit-libs/bukkit/build.gradle.kts
index a9d1c255e1..d8fb8a56f7 100644
--- a/worldedit-libs/bukkit/build.gradle.kts
+++ b/worldedit-libs/bukkit/build.gradle.kts
@@ -9,5 +9,5 @@ repositories {
}
dependencies {
- "shade"("net.kyori:text-adapter-bukkit:${Versions.TEXT_EXTRAS}")
+ "shade"(libs.kyoriText.adapter.bukkit)
}
diff --git a/worldedit-libs/core/ap/build.gradle.kts b/worldedit-libs/core/ap/build.gradle.kts
index a213eec78d..f610613073 100644
--- a/worldedit-libs/core/ap/build.gradle.kts
+++ b/worldedit-libs/core/ap/build.gradle.kts
@@ -2,6 +2,6 @@ applyLibrariesConfiguration()
dependencies {
// These are here because they use net.kyori:text-api -- so they need to be relocated too
- "shade"("org.enginehub.piston.core-ap:annotations:${Versions.PISTON}")
- "shade"("org.enginehub.piston.core-ap:processor:${Versions.PISTON}")
+ "shade"(libs.piston.coreAp.annotations)
+ "shade"(libs.piston.coreAp.processor)
}
diff --git a/worldedit-libs/core/build.gradle.kts b/worldedit-libs/core/build.gradle.kts
index a52f840423..abfd84c7ba 100644
--- a/worldedit-libs/core/build.gradle.kts
+++ b/worldedit-libs/core/build.gradle.kts
@@ -1,17 +1,18 @@
applyLibrariesConfiguration()
dependencies {
- "shade"("net.kyori:text-api:${Versions.TEXT}")
- "shade"("net.kyori:text-serializer-gson:${Versions.TEXT}")
- "shade"("net.kyori:text-serializer-legacy:${Versions.TEXT}")
- "shade"("net.kyori:text-serializer-plain:${Versions.TEXT}")
+ "shade"(libs.kyoriText.api)
+ "shade"(libs.kyoriText.serializer.gson)
+ "shade"(libs.kyoriText.serializer.legacy)
+ "shade"(libs.kyoriText.serializer.plain)
// These are here because they use net.kyori:text-api -- so they need to be relocated too
- "shade"("org.enginehub.piston:core:${Versions.PISTON}")
- "shade"("org.enginehub.piston.core-ap:runtime:${Versions.PISTON}")
- "shade"("org.enginehub.piston:default-impl:${Versions.PISTON}")
+ "shade"(libs.piston.core)
+ "shade"(libs.piston.coreAp.runtime)
+ "shade"(libs.piston.defaultImpl)
// Linbus
- "shade"("org.enginehub.lin-bus:lin-bus-common:${Versions.LIN_BUS}")
- "shade"("org.enginehub.lin-bus:lin-bus-stream:${Versions.LIN_BUS}")
- "shade"("org.enginehub.lin-bus:lin-bus-tree:${Versions.LIN_BUS}")
- "shade"("org.enginehub.lin-bus.format:lin-bus-format-snbt:${Versions.LIN_BUS}")
+ "shade"(platform(libs.linBus.bom))
+ "shade"(libs.linBus.common)
+ "shade"(libs.linBus.stream)
+ "shade"(libs.linBus.tree)
+ "shade"(libs.linBus.format.snbt)
}
diff --git a/worldedit-neoforge/build.gradle.kts b/worldedit-neoforge/build.gradle.kts
index 4460a66889..61213ef54e 100644
--- a/worldedit-neoforge/build.gradle.kts
+++ b/worldedit-neoforge/build.gradle.kts
@@ -9,11 +9,10 @@ plugins {
applyPlatformAndCoreConfiguration()
applyShadowConfiguration()
-val minecraftVersion = "1.20.5"
+val minecraftVersion = libs.versions.neoforge.minecraft.get()
val nextMajorMinecraftVersion: String = minecraftVersion.split('.').let { (useless, major) ->
"$useless.${major.toInt() + 1}"
}
-val neoVersion = "20.5.16-beta"
val apiClasspath = configurations.create("apiClasspath") {
isCanBeResolved = true
@@ -40,11 +39,8 @@ repositories {
dependencies {
"api"(project(":worldedit-core"))
- "implementation"(platform("org.apache.logging.log4j:log4j-bom:${Versions.LOG4J}") {
- because("Mojang provides Log4J")
- })
- "implementation"("net.neoforged:neoforge:$neoVersion")
+ "implementation"(libs.neoforge)
}
minecraft {
@@ -71,9 +67,8 @@ runs {
subsystems {
parchment {
- // https://parchmentmc.org/docs/getting-started; note that we use older MC versions some times which is OK
- minecraftVersion = "1.20.4"
- mappingsVersion = "2024.04.14"
+ minecraftVersion = libs.versions.parchment.minecraft.get()
+ mappingsVersion = libs.versions.parchment.mappings.get()
}
decompiler {
maxMemory("3G")
@@ -95,7 +90,7 @@ tasks.named("processResources") {
// this will ensure that this task is redone when the versions change.
val properties = mapOf(
"version" to project.ext["internalVersion"],
- "neoVersion" to neoVersion,
+ "neoVersion" to libs.neoforge.get().version,
"minecraftVersion" to minecraftVersion,
"nextMajorMinecraftVersion" to nextMajorMinecraftVersion
)
diff --git a/worldedit-sponge/build.gradle.kts b/worldedit-sponge/build.gradle.kts
index 3debe99bad..9da479e093 100644
--- a/worldedit-sponge/build.gradle.kts
+++ b/worldedit-sponge/build.gradle.kts
@@ -51,13 +51,9 @@ dependencies {
api(project(":worldedit-core"))
api(project(":worldedit-libs:sponge"))
- implementation(platform("org.apache.logging.log4j:log4j-bom:${Versions.LOG4J}") {
- because("Sponge 8 (will?) provides Log4J")
- })
api("org.apache.logging.log4j:log4j-api")
implementation("org.bstats:bstats-sponge:3.0.0")
implementation("it.unimi.dsi:fastutil")
- testImplementation("org.mockito:mockito-core:${Versions.MOCKITO}")
// Silence some warnings, since apparently this isn't on the compile classpath like it should be.
compileOnly("com.google.errorprone:error_prone_annotations:2.11.0")
From ada0a80faae4dfcf67daff189d81d3726045f1d9 Mon Sep 17 00:00:00 2001
From: Octavia Togami
Date: Mon, 29 Apr 2024 01:32:12 -0700
Subject: [PATCH 17/21] Use a normal platform for log4j-bom
---
buildSrc/src/main/kotlin/CommonConfig.kt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/buildSrc/src/main/kotlin/CommonConfig.kt b/buildSrc/src/main/kotlin/CommonConfig.kt
index 176ac48389..f3354f170f 100644
--- a/buildSrc/src/main/kotlin/CommonConfig.kt
+++ b/buildSrc/src/main/kotlin/CommonConfig.kt
@@ -45,7 +45,7 @@ fun Project.applyCommonConfiguration() {
if (!configurations.names.contains(conf)) {
continue
}
- add(conf, enforcedPlatform(stringyLibs.getLibrary("log4j-bom")).map {
+ add(conf, platform(stringyLibs.getLibrary("log4j-bom")).map {
val dep = create(it)
dep.because("Mojang provides Log4j")
dep
From 28ca2e6b961179f1c40040af75354dd2d2e81279 Mon Sep 17 00:00:00 2001
From: Octavia Togami
Date: Mon, 29 Apr 2024 17:29:02 -0700
Subject: [PATCH 18/21] Clean up Gradle configuration
---
{buildSrc => build-logic}/build.gradle.kts | 24 +-
{buildSrc => build-logic}/settings.gradle.kts | 0
.../main/kotlin/buildlogic.adapter.gradle.kts | 26 +
.../buildlogic.artifactory-root.gradle.kts | 35 +
.../buildlogic.artifactory-sub.gradle.kts | 10 +
.../kotlin/buildlogic.common-java.gradle.kts | 82 +
.../main/kotlin/buildlogic.common.gradle.kts | 68 +
.../buildlogic.core-and-platform.gradle.kts | 23 +
.../main/kotlin/buildlogic.libs.gradle.kts | 180 ++
.../kotlin/buildlogic.platform.gradle.kts | 53 +
.../kotlin/buildlogic/CommonJavaExtension.kt | 7 +
.../main/kotlin/buildlogic}/GradleExtras.kt | 2 +
.../kotlin/buildlogic/PlatformExtension.kt | 19 +
.../japicmp/accept/AbstractAcceptingRule.kt | 0
.../AcceptedRegressionsRulePostProcess.kt | 0
.../japicmp/accept/AcceptingSetupRule.kt | 0
.../kotlin/japicmp/accept/BinaryCompatRule.kt | 0
.../kotlin/japicmp/accept/ChangeParams.kt | 0
.../src/main/kotlin/japicmp/accept/LICENSE.md | 0
.../main/kotlin/japicmp/accept/apichanges.kt | 0
.../main/kotlin/japicmp/accept/userdata.kt | 0
build.gradle.kts | 29 +-
buildSrc/src/main/kotlin/AdapterConfig.kt | 29 -
buildSrc/src/main/kotlin/ArtifactoryConfig.kt | 43 -
buildSrc/src/main/kotlin/CommonConfig.kt | 82 -
buildSrc/src/main/kotlin/CommonJavaConfig.kt | 91 -
buildSrc/src/main/kotlin/LibsConfig.kt | 214 --
buildSrc/src/main/kotlin/PlatformConfig.kt | 98 -
gradle/libs.versions.toml | 13 +-
settings.gradle.kts | 21 +-
verification/build.gradle.kts | 27 +-
.../adapters/adapter-1.18.2/build.gradle.kts | 8 -
.../impl/v1_18_R2/PaperweightAdapter.java | 1061 -------
.../v1_18_R2/PaperweightDataConverters.java | 2800 -----------------
.../impl/v1_18_R2/PaperweightFakePlayer.java | 98 -
.../PaperweightWorldNativeAccess.java | 189 --
.../adapters/adapter-1.19.4/build.gradle.kts | 4 +-
.../adapters/adapter-1.20.2/build.gradle.kts | 4 +-
.../adapters/adapter-1.20.4/build.gradle.kts | 4 +-
.../adapters/adapter-1.20.5/build.gradle.kts | 4 +-
.../adapters/adapter-1.20/build.gradle.kts | 4 +-
worldedit-bukkit/build.gradle.kts | 15 +-
worldedit-cli/build.gradle.kts | 11 +-
worldedit-core/build.gradle.kts | 3 +-
worldedit-core/doctools/build.gradle.kts | 3 +-
worldedit-fabric/build.gradle.kts | 27 +-
worldedit-libs/bukkit/build.gradle.kts | 10 +-
worldedit-libs/cli/build.gradle.kts | 4 +-
worldedit-libs/core/ap/build.gradle.kts | 4 +-
worldedit-libs/core/build.gradle.kts | 4 +-
worldedit-libs/fabric/build.gradle.kts | 4 +-
worldedit-libs/neoforge/build.gradle.kts | 4 +-
worldedit-libs/sponge/build.gradle.kts | 11 -
worldedit-mod/build.gradle.kts | 4 +-
worldedit-neoforge/build.gradle.kts | 29 +-
worldedit-sponge/build.gradle.kts | 81 -
.../worldedit/sponge/CUIChannelHandler.java | 67 -
.../worldedit/sponge/CommandAdapter.java | 81 -
.../com/sk89q/worldedit/sponge/Constants.java | 39 -
.../sk89q/worldedit/sponge/SpongeAdapter.java | 249 --
.../worldedit/sponge/SpongeBiomeRegistry.java | 71 -
.../sponge/SpongeBlockCategoryRegistry.java | 44 -
.../sponge/SpongeBlockCommandSender.java | 183 --
.../worldedit/sponge/SpongeBlockMaterial.java | 96 -
.../worldedit/sponge/SpongeBlockRegistry.java | 91 -
.../worldedit/sponge/SpongeCommandSender.java | 172 -
.../sk89q/worldedit/sponge/SpongeEntity.java | 125 -
.../sponge/SpongeEntityProperties.java | 155 -
.../sponge/SpongeItemCategoryRegistry.java | 46 -
.../worldedit/sponge/SpongeItemRegistry.java | 47 -
.../sponge/SpongePermissionsProvider.java | 47 -
.../worldedit/sponge/SpongePlatform.java | 200 --
.../sk89q/worldedit/sponge/SpongePlayer.java | 308 --
.../worldedit/sponge/SpongeRegistries.java | 70 -
.../worldedit/sponge/SpongeTextAdapter.java | 45 -
.../sk89q/worldedit/sponge/SpongeWorld.java | 507 ---
.../worldedit/sponge/SpongeWorldEdit.java | 485 ---
.../worldedit/sponge/ThreadSafeCache.java | 63 -
.../config/ConfigurateConfiguration.java | 149 -
.../sponge/config/SpongeConfiguration.java | 62 -
.../sponge/internal/ExtendedChunk.java | 43 -
.../sponge/internal/LocaleResolver.java | 35 -
.../worldedit/sponge/internal/NbtAdapter.java | 272 --
.../sponge/internal/SpongeTransmogrifier.java | 210 --
.../internal/SpongeWorldNativeAccess.java | 159 -
85 files changed, 631 insertions(+), 9056 deletions(-)
rename {buildSrc => build-logic}/build.gradle.kts (59%)
rename {buildSrc => build-logic}/settings.gradle.kts (100%)
create mode 100644 build-logic/src/main/kotlin/buildlogic.adapter.gradle.kts
create mode 100644 build-logic/src/main/kotlin/buildlogic.artifactory-root.gradle.kts
create mode 100644 build-logic/src/main/kotlin/buildlogic.artifactory-sub.gradle.kts
create mode 100644 build-logic/src/main/kotlin/buildlogic.common-java.gradle.kts
create mode 100644 build-logic/src/main/kotlin/buildlogic.common.gradle.kts
create mode 100644 build-logic/src/main/kotlin/buildlogic.core-and-platform.gradle.kts
create mode 100644 build-logic/src/main/kotlin/buildlogic.libs.gradle.kts
create mode 100644 build-logic/src/main/kotlin/buildlogic.platform.gradle.kts
create mode 100644 build-logic/src/main/kotlin/buildlogic/CommonJavaExtension.kt
rename {buildSrc/src/main/kotlin => build-logic/src/main/kotlin/buildlogic}/GradleExtras.kt (98%)
create mode 100644 build-logic/src/main/kotlin/buildlogic/PlatformExtension.kt
rename {buildSrc => build-logic}/src/main/kotlin/japicmp/accept/AbstractAcceptingRule.kt (100%)
rename {buildSrc => build-logic}/src/main/kotlin/japicmp/accept/AcceptedRegressionsRulePostProcess.kt (100%)
rename {buildSrc => build-logic}/src/main/kotlin/japicmp/accept/AcceptingSetupRule.kt (100%)
rename {buildSrc => build-logic}/src/main/kotlin/japicmp/accept/BinaryCompatRule.kt (100%)
rename {buildSrc => build-logic}/src/main/kotlin/japicmp/accept/ChangeParams.kt (100%)
rename {buildSrc => build-logic}/src/main/kotlin/japicmp/accept/LICENSE.md (100%)
rename {buildSrc => build-logic}/src/main/kotlin/japicmp/accept/apichanges.kt (100%)
rename {buildSrc => build-logic}/src/main/kotlin/japicmp/accept/userdata.kt (100%)
delete mode 100644 buildSrc/src/main/kotlin/AdapterConfig.kt
delete mode 100644 buildSrc/src/main/kotlin/ArtifactoryConfig.kt
delete mode 100644 buildSrc/src/main/kotlin/CommonConfig.kt
delete mode 100644 buildSrc/src/main/kotlin/CommonJavaConfig.kt
delete mode 100644 buildSrc/src/main/kotlin/LibsConfig.kt
delete mode 100644 buildSrc/src/main/kotlin/PlatformConfig.kt
delete mode 100644 worldedit-bukkit/adapters/adapter-1.18.2/build.gradle.kts
delete mode 100644 worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightAdapter.java
delete mode 100644 worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightDataConverters.java
delete mode 100644 worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightFakePlayer.java
delete mode 100644 worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightWorldNativeAccess.java
delete mode 100644 worldedit-libs/sponge/build.gradle.kts
delete mode 100644 worldedit-sponge/build.gradle.kts
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/CUIChannelHandler.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/CommandAdapter.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/Constants.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeAdapter.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeBiomeRegistry.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeBlockCategoryRegistry.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeBlockCommandSender.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeBlockMaterial.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeBlockRegistry.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeCommandSender.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeEntity.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeEntityProperties.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeItemCategoryRegistry.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeItemRegistry.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePermissionsProvider.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlatform.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeRegistries.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeTextAdapter.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorldEdit.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/ThreadSafeCache.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/SpongeConfiguration.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/internal/ExtendedChunk.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/internal/LocaleResolver.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/internal/NbtAdapter.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/internal/SpongeTransmogrifier.java
delete mode 100644 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/internal/SpongeWorldNativeAccess.java
diff --git a/buildSrc/build.gradle.kts b/build-logic/build.gradle.kts
similarity index 59%
rename from buildSrc/build.gradle.kts
rename to build-logic/build.gradle.kts
index f277a4f592..7ded3026ea 100644
--- a/buildSrc/build.gradle.kts
+++ b/build-logic/build.gradle.kts
@@ -3,26 +3,7 @@ plugins {
}
repositories {
- maven {
- name = "PaperMC"
- url = uri("https://repo.papermc.io/repository/maven-public/")
- content {
- includeGroupAndSubgroups("io.papermc")
- }
- }
- maven {
- name = "NeoForged Maven"
- url = uri("https://maven.neoforged.net/releases")
- content {
- includeGroupAndSubgroups("net.neoforged")
- }
- }
- mavenCentral()
gradlePluginPortal()
- maven {
- name = "Fabric"
- url = uri("https://maven.fabricmc.net/")
- }
maven {
name = "EngineHub Repository"
url = uri("https://maven.enginehub.org/repo/")
@@ -36,11 +17,8 @@ dependencies {
implementation(libs.japicmp)
implementation(libs.shadow)
implementation(libs.jfrog.buildinfo)
- implementation(libs.neoGradle.userdev)
- implementation(libs.fabric.loom)
- implementation(libs.fabric.mixin)
- implementation(libs.codecov)
implementation(libs.paperweight)
+ implementation(libs.gson)
constraints {
val asmVersion = "[${libs.versions.minimumAsm.get()},)"
implementation("org.ow2.asm:asm:$asmVersion") {
diff --git a/buildSrc/settings.gradle.kts b/build-logic/settings.gradle.kts
similarity index 100%
rename from buildSrc/settings.gradle.kts
rename to build-logic/settings.gradle.kts
diff --git a/build-logic/src/main/kotlin/buildlogic.adapter.gradle.kts b/build-logic/src/main/kotlin/buildlogic.adapter.gradle.kts
new file mode 100644
index 0000000000..58fce0a239
--- /dev/null
+++ b/build-logic/src/main/kotlin/buildlogic.adapter.gradle.kts
@@ -0,0 +1,26 @@
+import buildlogic.stringyLibs
+import buildlogic.getVersion
+
+plugins {
+ `java-library`
+ id("buildlogic.common")
+ id("buildlogic.common-java")
+ id("io.papermc.paperweight.userdev")
+}
+
+configure {
+ banSlf4j = false
+}
+
+dependencies {
+ "implementation"(project(":worldedit-bukkit"))
+ constraints {
+ "remapper"("net.fabricmc:tiny-remapper:[${stringyLibs.getVersion("minimumTinyRemapper")},)") {
+ because("Need remapper to support Java 21")
+ }
+ }
+}
+
+tasks.named("assemble") {
+ dependsOn("reobfJar")
+}
diff --git a/build-logic/src/main/kotlin/buildlogic.artifactory-root.gradle.kts b/build-logic/src/main/kotlin/buildlogic.artifactory-root.gradle.kts
new file mode 100644
index 0000000000..c3b4f8310d
--- /dev/null
+++ b/build-logic/src/main/kotlin/buildlogic.artifactory-root.gradle.kts
@@ -0,0 +1,35 @@
+import org.gradle.api.Project
+import org.gradle.kotlin.dsl.configure
+import org.gradle.kotlin.dsl.named
+import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention
+import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask
+
+plugins {
+ id("com.jfrog.artifactory")
+}
+
+val ARTIFACTORY_CONTEXT_URL = "artifactory_contextUrl"
+val ARTIFACTORY_USER = "artifactory_user"
+val ARTIFACTORY_PASSWORD = "artifactory_password"
+
+if (!project.hasProperty(ARTIFACTORY_CONTEXT_URL)) ext[ARTIFACTORY_CONTEXT_URL] = "http://localhost"
+if (!project.hasProperty(ARTIFACTORY_USER)) ext[ARTIFACTORY_USER] = "guest"
+if (!project.hasProperty(ARTIFACTORY_PASSWORD)) ext[ARTIFACTORY_PASSWORD] = ""
+
+configure {
+ setContextUrl("${project.property(ARTIFACTORY_CONTEXT_URL)}")
+ clientConfig.publisher.run {
+ repoKey = when {
+ "${project.version}".contains("SNAPSHOT") -> "libs-snapshot-local"
+ else -> "libs-release-local"
+ }
+ username = "${project.property(ARTIFACTORY_USER)}"
+ password = "${project.property(ARTIFACTORY_PASSWORD)}"
+ isMaven = true
+ isIvy = false
+ }
+}
+
+tasks.named("artifactoryPublish") {
+ isSkip = true
+}
diff --git a/build-logic/src/main/kotlin/buildlogic.artifactory-sub.gradle.kts b/build-logic/src/main/kotlin/buildlogic.artifactory-sub.gradle.kts
new file mode 100644
index 0000000000..966409761f
--- /dev/null
+++ b/build-logic/src/main/kotlin/buildlogic.artifactory-sub.gradle.kts
@@ -0,0 +1,10 @@
+plugins {
+ id("com.jfrog.artifactory")
+}
+
+// Artifactory eagerly evaluates publications, so this must run after all changes to artifacts are done
+afterEvaluate {
+ tasks.named("artifactoryPublish") {
+ publications("maven")
+ }
+}
diff --git a/build-logic/src/main/kotlin/buildlogic.common-java.gradle.kts b/build-logic/src/main/kotlin/buildlogic.common-java.gradle.kts
new file mode 100644
index 0000000000..48387042f5
--- /dev/null
+++ b/build-logic/src/main/kotlin/buildlogic.common-java.gradle.kts
@@ -0,0 +1,82 @@
+import buildlogic.stringyLibs
+import buildlogic.getLibrary
+
+plugins {
+ id("eclipse")
+ id("idea")
+ id("checkstyle")
+ id("buildlogic.common")
+}
+
+val commonJava = extensions.create("commonJava")
+commonJava.banSlf4j.convention(true)
+
+tasks
+ .withType()
+ .matching { it.name == "compileJava" || it.name == "compileTestJava" }
+ .configureEach {
+ // TODO: re-enable this-escape when ANTLR suppresses it properly
+ val disabledLint = listOf(
+ "processing", "path", "fallthrough", "serial", "overloads", "this-escape",
+ )
+ options.release.set(21)
+ options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" })
+ options.isDeprecation = true
+ options.encoding = "UTF-8"
+ options.compilerArgs.add("-parameters")
+ options.compilerArgs.add("-Werror")
+ }
+
+configure {
+ configFile = rootProject.file("config/checkstyle/checkstyle.xml")
+ toolVersion = "9.1"
+}
+
+tasks.withType().configureEach {
+ useJUnitPlatform()
+}
+
+dependencies {
+ "compileOnly"(stringyLibs.getLibrary("jsr305"))
+ "testImplementation"(platform(stringyLibs.getLibrary("junit-bom")))
+ "testImplementation"(stringyLibs.getLibrary("junit-jupiter-api"))
+ "testImplementation"(stringyLibs.getLibrary("junit-jupiter-params"))
+ "testImplementation"(platform(stringyLibs.getLibrary("mockito-bom")))
+ "testImplementation"(stringyLibs.getLibrary("mockito-core"))
+ "testImplementation"(stringyLibs.getLibrary("mockito-junit-jupiter"))
+ "testRuntimeOnly"(stringyLibs.getLibrary("junit-jupiter-engine"))
+}
+
+// Java 8 turns on doclint which we fail
+tasks.withType().configureEach {
+ options.encoding = "UTF-8"
+ (options as StandardJavadocDocletOptions).apply {
+ addBooleanOption("Werror", true)
+ addBooleanOption("Xdoclint:all", true)
+ addBooleanOption("Xdoclint:-missing", true)
+ tags(
+ "apiNote:a:API Note:",
+ "implSpec:a:Implementation Requirements:",
+ "implNote:a:Implementation Note:"
+ )
+ }
+}
+
+configure {
+ withJavadocJar()
+ withSourcesJar()
+}
+
+configurations["compileClasspath"].apply {
+ resolutionStrategy.componentSelection {
+ withModule("org.slf4j:slf4j-api") {
+ if (commonJava.banSlf4j.get()) {
+ reject("No SLF4J allowed on compile classpath")
+ }
+ }
+ }
+}
+
+tasks.named("check").configure {
+ dependsOn("checkstyleMain", "checkstyleTest")
+}
diff --git a/build-logic/src/main/kotlin/buildlogic.common.gradle.kts b/build-logic/src/main/kotlin/buildlogic.common.gradle.kts
new file mode 100644
index 0000000000..91006dfea0
--- /dev/null
+++ b/build-logic/src/main/kotlin/buildlogic.common.gradle.kts
@@ -0,0 +1,68 @@
+import buildlogic.getLibrary
+import buildlogic.stringyLibs
+import org.gradle.plugins.ide.idea.model.IdeaModel
+
+plugins {
+ id("org.cadixdev.licenser")
+}
+
+group = rootProject.group
+version = rootProject.version
+
+repositories {
+ maven {
+ name = "EngineHub"
+ url = uri("https://maven.enginehub.org/repo/")
+ }
+}
+
+configurations.all {
+ resolutionStrategy {
+ cacheChangingModulesFor(1, TimeUnit.DAYS)
+ }
+}
+
+plugins.withId("java") {
+ the().toolchain {
+ languageVersion.set(JavaLanguageVersion.of(21))
+ }
+}
+
+dependencies {
+ for (conf in listOf("implementation", "api")) {
+ if (!configurations.names.contains(conf)) {
+ continue
+ }
+ add(conf, platform(stringyLibs.getLibrary("log4j-bom")).map {
+ val dep = create(it)
+ dep.because("Mojang provides Log4j")
+ dep
+ })
+ constraints {
+ add(conf, stringyLibs.getLibrary("guava")) {
+ because("Mojang provides Guava")
+ }
+ add(conf, stringyLibs.getLibrary("gson")) {
+ because("Mojang provides Gson")
+ }
+ add(conf, stringyLibs.getLibrary("fastutil")) {
+ because("Mojang provides FastUtil")
+ }
+ }
+ }
+}
+
+license {
+ header(rootProject.file("HEADER.txt"))
+ include("**/*.java")
+ include("**/*.kt")
+}
+
+plugins.withId("idea") {
+ configure {
+ module {
+ isDownloadSources = true
+ isDownloadJavadoc = true
+ }
+ }
+}
diff --git a/build-logic/src/main/kotlin/buildlogic.core-and-platform.gradle.kts b/build-logic/src/main/kotlin/buildlogic.core-and-platform.gradle.kts
new file mode 100644
index 0000000000..ce369ccec0
--- /dev/null
+++ b/build-logic/src/main/kotlin/buildlogic.core-and-platform.gradle.kts
@@ -0,0 +1,23 @@
+plugins {
+ id("java")
+ id("maven-publish")
+ id("buildlogic.common-java")
+ id("buildlogic.artifactory-sub")
+}
+
+ext["internalVersion"] = "$version+${rootProject.ext["gitCommitHash"]}"
+
+publishing {
+ publications {
+ register("maven") {
+ versionMapping {
+ usage("java-api") {
+ fromResolutionOf("runtimeClasspath")
+ }
+ usage("java-runtime") {
+ fromResolutionResult()
+ }
+ }
+ }
+ }
+}
diff --git a/build-logic/src/main/kotlin/buildlogic.libs.gradle.kts b/build-logic/src/main/kotlin/buildlogic.libs.gradle.kts
new file mode 100644
index 0000000000..653c7d09c2
--- /dev/null
+++ b/build-logic/src/main/kotlin/buildlogic.libs.gradle.kts
@@ -0,0 +1,180 @@
+plugins {
+ id("java-base")
+ id("maven-publish")
+ id("com.github.johnrengelman.shadow")
+ id("com.jfrog.artifactory")
+ id("buildlogic.common")
+ id("buildlogic.artifactory-sub")
+}
+
+// A horrible hack because `softwareComponentFactory` has to be gotten via plugin
+// gradle why
+internal open class LibsConfigPluginHack @Inject constructor(
+ private val softwareComponentFactory: SoftwareComponentFactory
+) : Plugin {
+ override fun apply(project: Project) {
+ val libsComponents = softwareComponentFactory.adhoc("libs")
+ project.components.add(libsComponents)
+ }
+}
+
+configurations {
+ create("shade")
+}
+
+group = "${rootProject.group}.worldedit-libs"
+
+val relocations = mapOf(
+ "net.kyori.text" to "com.sk89q.worldedit.util.formatting.text",
+ "net.kyori.minecraft" to "com.sk89q.worldedit.util.kyori",
+)
+
+tasks.register("jar") {
+ configurations = listOf(project.configurations["shade"])
+ archiveClassifier.set("")
+
+ // Yeet module-info's
+ exclude("module-info.class")
+
+ dependencies {
+ exclude(dependency("com.google.guava:guava"))
+ exclude(dependency("com.google.code.gson:gson"))
+ exclude(dependency("com.google.errorprone:error_prone_annotations"))
+ exclude(dependency("com.google.guava:failureaccess"))
+ exclude(dependency("org.checkerframework:checker-qual"))
+ exclude(dependency("org.jetbrains:annotations"))
+ exclude(dependency("org.apache.logging.log4j:log4j-api"))
+ exclude(dependency("com.google.code.findbugs:jsr305"))
+ exclude {
+ it.moduleGroup == "org.jetbrains.kotlin"
+ }
+ }
+
+ relocations.forEach { (from, to) ->
+ relocate(from, to)
+ }
+}
+val altConfigFiles = { artifactType: String ->
+ val deps = configurations["shade"].incoming.dependencies
+ .filterIsInstance()
+ .map { it.copy() }
+ .map { dependency ->
+ val category = dependency.attributes.getAttribute(Category.CATEGORY_ATTRIBUTE)?.name
+ if (category == Category.REGULAR_PLATFORM || category == Category.ENFORCED_PLATFORM) {
+ return@map dependency
+ }
+ try {
+ dependency.artifact {
+ name = dependency.name
+ type = artifactType
+ extension = "jar"
+ classifier = artifactType
+ }
+ } catch (e: Exception) {
+ throw RuntimeException("Failed to add artifact to dependency: $dependency", e)
+ }
+ dependency
+ }
+
+ files(configurations.detachedConfiguration(*deps.toTypedArray())
+ .resolvedConfiguration.lenientConfiguration.artifacts
+ .filter { it.classifier == artifactType }
+ .map { zipTree(it.file) })
+}
+tasks.register("sourcesJar") {
+ from({
+ altConfigFiles("sources")
+ })
+
+ // Yeet module-info's
+ exclude("module-info.java")
+
+ relocations.forEach { (from, to) ->
+ val filePattern = Regex("(.*)${from.replace('.', '/')}((?:/|$).*)")
+ val textPattern = Regex.fromLiteral(from)
+ eachFile {
+ filter {
+ it.replaceFirst(textPattern, to)
+ }
+ path = path.replaceFirst(filePattern, "$1${to.replace('.', '/')}$2")
+ }
+ }
+ archiveClassifier.set("sources")
+}
+
+tasks.named("assemble").configure {
+ dependsOn("jar", "sourcesJar")
+}
+
+project.apply()
+
+val libsComponent = project.components["libs"] as AdhocComponentWithVariants
+
+val apiElements = project.configurations.register("apiElements") {
+ isVisible = false
+ description = "API elements for libs"
+ isCanBeResolved = false
+ isCanBeConsumed = true
+ attributes {
+ attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_API))
+ attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY))
+ attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED))
+ attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR))
+ attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 16)
+ }
+ outgoing.artifact(tasks.named("jar"))
+}
+
+val runtimeElements = project.configurations.register("runtimeElements") {
+ isVisible = false
+ description = "Runtime elements for libs"
+ isCanBeResolved = false
+ isCanBeConsumed = true
+ attributes {
+ attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_RUNTIME))
+ attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY))
+ attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED))
+ attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR))
+ attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 16)
+ }
+ outgoing.artifact(tasks.named("jar"))
+}
+
+val sourcesElements = project.configurations.register("sourcesElements") {
+ isVisible = false
+ description = "Source elements for libs"
+ isCanBeResolved = false
+ isCanBeConsumed = true
+ attributes {
+ attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_RUNTIME))
+ attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.DOCUMENTATION))
+ attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED))
+ attribute(DocsType.DOCS_TYPE_ATTRIBUTE, project.objects.named(DocsType.SOURCES))
+ }
+ outgoing.artifact(tasks.named("sourcesJar"))
+}
+
+libsComponent.addVariantsFromConfiguration(apiElements.get()) {
+ mapToMavenScope("compile")
+}
+
+libsComponent.addVariantsFromConfiguration(runtimeElements.get()) {
+ mapToMavenScope("runtime")
+}
+
+libsComponent.addVariantsFromConfiguration(sourcesElements.get()) {
+ mapToMavenScope("runtime")
+}
+
+configure {
+ publications {
+ register("maven") {
+ from(libsComponent)
+ }
+ }
+}
+
+if (project != project(":worldedit-libs:core")) {
+ evaluationDependsOn(":worldedit-libs:core")
+ configurations["shade"].shouldResolveConsistentlyWith(project(":worldedit-libs:core").configurations["shade"])
+}
diff --git a/build-logic/src/main/kotlin/buildlogic.platform.gradle.kts b/build-logic/src/main/kotlin/buildlogic.platform.gradle.kts
new file mode 100644
index 0000000000..2597947718
--- /dev/null
+++ b/build-logic/src/main/kotlin/buildlogic.platform.gradle.kts
@@ -0,0 +1,53 @@
+plugins {
+ id("com.github.johnrengelman.shadow")
+ id("buildlogic.core-and-platform")
+}
+
+val platform = extensions.create("platform")
+platform.includeClasspath.convention(false)
+platform.extraAttributes.convention(mapOf())
+
+tasks.named("shadowJar") {
+ archiveClassifier.set("dist")
+ dependencies {
+ include(project(":worldedit-libs:core"))
+ include(project(":worldedit-libs:${project.name.replace("worldedit-", "")}"))
+ include(project(":worldedit-core"))
+ exclude("com.google.code.findbugs:jsr305")
+ }
+ exclude("GradleStart**")
+ exclude(".cache")
+ exclude("LICENSE*")
+ exclude("META-INF/maven/**")
+ minimize()
+}
+val javaComponent = components["java"] as AdhocComponentWithVariants
+// I don't think we want this published (it's the shadow jar)
+javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
+ skip()
+}
+
+afterEvaluate {
+ tasks.named("jar") {
+ val kind = platform.kind.get()
+ val includeClasspath = platform.includeClasspath.get()
+ val extraAttributes = platform.extraAttributes.get()
+
+ val version = project(":worldedit-core").version
+ inputs.property("version", version)
+ val attributes = mutableMapOf(
+ "Implementation-Version" to version,
+ "WorldEdit-Version" to version,
+ "WorldEdit-Kind" to kind.name,
+ "Main-Class" to kind.mainClass
+ )
+ if (includeClasspath) {
+ attributes["Class-Path"] = listOf("truezip", "truevfs", "js")
+ .map { "$it.jar" }
+ .flatMap { listOf(it, "WorldEdit/$it") }
+ .joinToString(separator = " ")
+ }
+ attributes.putAll(extraAttributes)
+ manifest.attributes(attributes)
+ }
+}
diff --git a/build-logic/src/main/kotlin/buildlogic/CommonJavaExtension.kt b/build-logic/src/main/kotlin/buildlogic/CommonJavaExtension.kt
new file mode 100644
index 0000000000..8631f53794
--- /dev/null
+++ b/build-logic/src/main/kotlin/buildlogic/CommonJavaExtension.kt
@@ -0,0 +1,7 @@
+package buildlogic
+
+import org.gradle.api.provider.Property
+
+interface CommonJavaExtension {
+ val banSlf4j: Property
+}
diff --git a/buildSrc/src/main/kotlin/GradleExtras.kt b/build-logic/src/main/kotlin/buildlogic/GradleExtras.kt
similarity index 98%
rename from buildSrc/src/main/kotlin/GradleExtras.kt
rename to build-logic/src/main/kotlin/buildlogic/GradleExtras.kt
index e6d1fa3c66..77b0059dbc 100644
--- a/buildSrc/src/main/kotlin/GradleExtras.kt
+++ b/build-logic/src/main/kotlin/buildlogic/GradleExtras.kt
@@ -1,3 +1,5 @@
+package buildlogic
+
import org.gradle.api.Project
import org.gradle.api.artifacts.MinimalExternalModuleDependency
import org.gradle.api.artifacts.VersionCatalog
diff --git a/build-logic/src/main/kotlin/buildlogic/PlatformExtension.kt b/build-logic/src/main/kotlin/buildlogic/PlatformExtension.kt
new file mode 100644
index 0000000000..d27a3e4955
--- /dev/null
+++ b/build-logic/src/main/kotlin/buildlogic/PlatformExtension.kt
@@ -0,0 +1,19 @@
+package buildlogic
+
+import org.gradle.api.provider.MapProperty
+import org.gradle.api.provider.Property
+
+interface PlatformExtension {
+ val kind: Property
+ val includeClasspath: Property
+ val extraAttributes: MapProperty
+}
+
+sealed class WorldEditKind(
+ val name: String,
+ val mainClass: String = "com.sk89q.worldedit.internal.util.InfoEntryPoint"
+) {
+ class Standalone(mainClass: String) : WorldEditKind("STANDALONE", mainClass)
+ object Mod : WorldEditKind("MOD")
+ object Plugin : WorldEditKind("PLUGIN")
+}
diff --git a/buildSrc/src/main/kotlin/japicmp/accept/AbstractAcceptingRule.kt b/build-logic/src/main/kotlin/japicmp/accept/AbstractAcceptingRule.kt
similarity index 100%
rename from buildSrc/src/main/kotlin/japicmp/accept/AbstractAcceptingRule.kt
rename to build-logic/src/main/kotlin/japicmp/accept/AbstractAcceptingRule.kt
diff --git a/buildSrc/src/main/kotlin/japicmp/accept/AcceptedRegressionsRulePostProcess.kt b/build-logic/src/main/kotlin/japicmp/accept/AcceptedRegressionsRulePostProcess.kt
similarity index 100%
rename from buildSrc/src/main/kotlin/japicmp/accept/AcceptedRegressionsRulePostProcess.kt
rename to build-logic/src/main/kotlin/japicmp/accept/AcceptedRegressionsRulePostProcess.kt
diff --git a/buildSrc/src/main/kotlin/japicmp/accept/AcceptingSetupRule.kt b/build-logic/src/main/kotlin/japicmp/accept/AcceptingSetupRule.kt
similarity index 100%
rename from buildSrc/src/main/kotlin/japicmp/accept/AcceptingSetupRule.kt
rename to build-logic/src/main/kotlin/japicmp/accept/AcceptingSetupRule.kt
diff --git a/buildSrc/src/main/kotlin/japicmp/accept/BinaryCompatRule.kt b/build-logic/src/main/kotlin/japicmp/accept/BinaryCompatRule.kt
similarity index 100%
rename from buildSrc/src/main/kotlin/japicmp/accept/BinaryCompatRule.kt
rename to build-logic/src/main/kotlin/japicmp/accept/BinaryCompatRule.kt
diff --git a/buildSrc/src/main/kotlin/japicmp/accept/ChangeParams.kt b/build-logic/src/main/kotlin/japicmp/accept/ChangeParams.kt
similarity index 100%
rename from buildSrc/src/main/kotlin/japicmp/accept/ChangeParams.kt
rename to build-logic/src/main/kotlin/japicmp/accept/ChangeParams.kt
diff --git a/buildSrc/src/main/kotlin/japicmp/accept/LICENSE.md b/build-logic/src/main/kotlin/japicmp/accept/LICENSE.md
similarity index 100%
rename from buildSrc/src/main/kotlin/japicmp/accept/LICENSE.md
rename to build-logic/src/main/kotlin/japicmp/accept/LICENSE.md
diff --git a/buildSrc/src/main/kotlin/japicmp/accept/apichanges.kt b/build-logic/src/main/kotlin/japicmp/accept/apichanges.kt
similarity index 100%
rename from buildSrc/src/main/kotlin/japicmp/accept/apichanges.kt
rename to build-logic/src/main/kotlin/japicmp/accept/apichanges.kt
diff --git a/buildSrc/src/main/kotlin/japicmp/accept/userdata.kt b/build-logic/src/main/kotlin/japicmp/accept/userdata.kt
similarity index 100%
rename from buildSrc/src/main/kotlin/japicmp/accept/userdata.kt
rename to build-logic/src/main/kotlin/japicmp/accept/userdata.kt
diff --git a/build.gradle.kts b/build.gradle.kts
index 939ab60971..0f5d6e5649 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,21 +1,25 @@
import org.ajoberstar.grgit.Grgit
-// needed for fabric to know where FF executor is....
buildscript {
repositories {
- mavenCentral()
+ maven {
+ name = "EngineHub"
+ url = uri("https://maven.enginehub.org/repo/")
+ }
maven {
name = "Fabric"
url = uri("https://maven.fabricmc.net/")
}
}
dependencies {
- classpath(libs.fabric.loom)
+ // needed for fabric to know where FF executor is....
}
}
plugins {
- id("org.enginehub.codecov")
+ alias(libs.plugins.codecov)
jacoco
+ id("buildlogic.common")
+ id("buildlogic.artifactory-root")
}
if (!project.hasProperty("gitCommitHash")) {
@@ -29,23 +33,6 @@ if (!project.hasProperty("gitCommitHash")) {
}
}
-logger.lifecycle("""
-*******************************************
- You are building WorldEdit!
-
- If you encounter trouble:
- 1) Read COMPILING.md if you haven't yet
- 2) Try running 'build' in a separate Gradle run
- 3) Use gradlew and not gradle
- 4) If you still need help, ask on Discord! https://discord.gg/enginehub
-
- Output files will be in [subproject]/build/libs
-*******************************************
-""")
-
-applyCommonConfiguration()
-applyRootArtifactoryConfig()
-
val totalReport = tasks.register("jacocoTotalReport") {
for (proj in subprojects) {
proj.apply(plugin = "jacoco")
diff --git a/buildSrc/src/main/kotlin/AdapterConfig.kt b/buildSrc/src/main/kotlin/AdapterConfig.kt
deleted file mode 100644
index 240a623d29..0000000000
--- a/buildSrc/src/main/kotlin/AdapterConfig.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-import org.gradle.api.Project
-import org.gradle.kotlin.dsl.apply
-import org.gradle.kotlin.dsl.dependencies
-
-// For specific version pinning, see
-// https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
-fun Project.applyPaperweightAdapterConfiguration(javaRelease: Int = 21) {
- applyCommonConfiguration()
- apply(plugin = "java-library")
- applyCommonJavaConfiguration(
- sourcesJar = true,
- javaRelease = javaRelease,
- banSlf4j = false,
- )
- apply(plugin = "io.papermc.paperweight.userdev")
-
- dependencies {
- "implementation"(project(":worldedit-bukkit"))
- constraints {
- "remapper"("net.fabricmc:tiny-remapper:[${stringyLibs.getVersion("minimumTinyRemapper")},)") {
- because("Need remapper to support Java 21")
- }
- }
- }
-
- tasks.named("assemble") {
- dependsOn("reobfJar")
- }
-}
diff --git a/buildSrc/src/main/kotlin/ArtifactoryConfig.kt b/buildSrc/src/main/kotlin/ArtifactoryConfig.kt
deleted file mode 100644
index fade874543..0000000000
--- a/buildSrc/src/main/kotlin/ArtifactoryConfig.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-import org.gradle.api.Project
-import org.gradle.kotlin.dsl.apply
-import org.gradle.kotlin.dsl.configure
-import org.gradle.kotlin.dsl.named
-import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention
-import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask
-
-private const val ARTIFACTORY_CONTEXT_URL = "artifactory_contextUrl"
-private const val ARTIFACTORY_USER = "artifactory_user"
-private const val ARTIFACTORY_PASSWORD = "artifactory_password"
-
-fun Project.applyRootArtifactoryConfig() {
- if (!project.hasProperty(ARTIFACTORY_CONTEXT_URL)) ext[ARTIFACTORY_CONTEXT_URL] = "http://localhost"
- if (!project.hasProperty(ARTIFACTORY_USER)) ext[ARTIFACTORY_USER] = "guest"
- if (!project.hasProperty(ARTIFACTORY_PASSWORD)) ext[ARTIFACTORY_PASSWORD] = ""
-
- apply(plugin = "com.jfrog.artifactory")
- configure {
- setContextUrl("${project.property(ARTIFACTORY_CONTEXT_URL)}")
- clientConfig.publisher.run {
- repoKey = when {
- "${project.version}".contains("SNAPSHOT") -> "libs-snapshot-local"
- else -> "libs-release-local"
- }
- username = "${project.property(ARTIFACTORY_USER)}"
- password = "${project.property(ARTIFACTORY_PASSWORD)}"
- isMaven = true
- isIvy = false
- }
- }
- tasks.named("artifactoryPublish") {
- isSkip = true
- }
-}
-
-fun Project.applyCommonArtifactoryConfig() {
- // Artifactory eagerly evaluates publications, so this must run after all changes to artifacts are done
- afterEvaluate {
- tasks.named("artifactoryPublish") {
- publications("maven")
- }
- }
-}
diff --git a/buildSrc/src/main/kotlin/CommonConfig.kt b/buildSrc/src/main/kotlin/CommonConfig.kt
deleted file mode 100644
index f3354f170f..0000000000
--- a/buildSrc/src/main/kotlin/CommonConfig.kt
+++ /dev/null
@@ -1,82 +0,0 @@
-import groovy.lang.Closure
-import org.cadixdev.gradle.licenser.LicenseExtension
-import org.gradle.api.Project
-import org.gradle.api.artifacts.Dependency
-import org.gradle.api.artifacts.ExternalModuleDependency
-import org.gradle.api.plugins.JavaPluginExtension
-import org.gradle.jvm.toolchain.JavaLanguageVersion
-import org.gradle.kotlin.dsl.*
-import org.gradle.plugins.ide.idea.model.IdeaModel
-import java.util.concurrent.TimeUnit
-
-fun Project.applyCommonConfiguration() {
- group = rootProject.group
- version = rootProject.version
-
- repositories {
- mavenCentral {
- mavenContent {
- releasesOnly()
- }
- }
- maven { url = uri("https://maven.enginehub.org/repo/") }
- maven {
- url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
- mavenContent {
- snapshotsOnly()
- }
- }
- }
-
- configurations.all {
- resolutionStrategy {
- cacheChangingModulesFor(1, TimeUnit.DAYS)
- }
- }
-
- plugins.withId("java") {
- the().toolchain {
- languageVersion.set(JavaLanguageVersion.of(21))
- }
- }
-
- dependencies {
- for (conf in listOf("implementation", "api")) {
- if (!configurations.names.contains(conf)) {
- continue
- }
- add(conf, platform(stringyLibs.getLibrary("log4j-bom")).map {
- val dep = create(it)
- dep.because("Mojang provides Log4j")
- dep
- })
- constraints {
- add(conf, stringyLibs.getLibrary("guava")) {
- because("Mojang provides Guava")
- }
- add(conf, stringyLibs.getLibrary("gson")) {
- because("Mojang provides Gson")
- }
- add(conf, stringyLibs.getLibrary("fastutil")) {
- because("Mojang provides FastUtil")
- }
- }
- }
- }
-
- apply(plugin = "org.cadixdev.licenser")
- configure {
- header(rootProject.file("HEADER.txt"))
- include("**/*.java")
- include("**/*.kt")
- }
-
- plugins.withId("idea") {
- configure {
- module {
- isDownloadSources = true
- isDownloadJavadoc = true
- }
- }
- }
-}
diff --git a/buildSrc/src/main/kotlin/CommonJavaConfig.kt b/buildSrc/src/main/kotlin/CommonJavaConfig.kt
deleted file mode 100644
index 3c58b86ead..0000000000
--- a/buildSrc/src/main/kotlin/CommonJavaConfig.kt
+++ /dev/null
@@ -1,91 +0,0 @@
-import org.gradle.api.Project
-import org.gradle.api.plugins.JavaPluginExtension
-import org.gradle.api.plugins.quality.CheckstyleExtension
-import org.gradle.api.tasks.compile.JavaCompile
-import org.gradle.api.tasks.javadoc.Javadoc
-import org.gradle.api.tasks.testing.Test
-import org.gradle.external.javadoc.StandardJavadocDocletOptions
-import org.gradle.kotlin.dsl.apply
-import org.gradle.kotlin.dsl.configure
-import org.gradle.kotlin.dsl.dependencies
-import org.gradle.kotlin.dsl.get
-import org.gradle.kotlin.dsl.withType
-
-fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, javaRelease: Int = 17, banSlf4j: Boolean = true) {
- applyCommonConfiguration()
- apply(plugin = "eclipse")
- apply(plugin = "idea")
- apply(plugin = "checkstyle")
-
- tasks
- .withType()
- .matching { it.name == "compileJava" || it.name == "compileTestJava" }
- .configureEach {
- // TODO: re-enable this-escape when ANTLR suppresses it properly
- val disabledLint = listOf(
- "processing", "path", "fallthrough", "serial", "overloads", "this-escape",
- )
- options.release.set(javaRelease)
- options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" })
- options.isDeprecation = true
- options.encoding = "UTF-8"
- options.compilerArgs.add("-parameters")
- options.compilerArgs.add("-Werror")
- }
-
- configure {
- configFile = rootProject.file("config/checkstyle/checkstyle.xml")
- toolVersion = "9.1"
- }
-
- tasks.withType().configureEach {
- useJUnitPlatform()
- }
-
- dependencies {
- "compileOnly"(stringyLibs.getLibrary("jsr305"))
- "testImplementation"(platform(stringyLibs.getLibrary("junit-bom")))
- "testImplementation"(stringyLibs.getLibrary("junit-jupiter-api"))
- "testImplementation"(stringyLibs.getLibrary("junit-jupiter-params"))
- "testImplementation"(platform(stringyLibs.getLibrary("mockito-bom")))
- "testImplementation"(stringyLibs.getLibrary("mockito-core"))
- "testImplementation"(stringyLibs.getLibrary("mockito-junit-jupiter"))
- "testRuntimeOnly"(stringyLibs.getLibrary("junit-jupiter-engine"))
- }
-
- // Java 8 turns on doclint which we fail
- tasks.withType().configureEach {
- options.encoding = "UTF-8"
- (options as StandardJavadocDocletOptions).apply {
- addBooleanOption("Werror", true)
- addBooleanOption("Xdoclint:all", true)
- addBooleanOption("Xdoclint:-missing", true)
- tags(
- "apiNote:a:API Note:",
- "implSpec:a:Implementation Requirements:",
- "implNote:a:Implementation Note:"
- )
- }
- }
-
- configure {
- withJavadocJar()
- if (sourcesJar) {
- withSourcesJar()
- }
- }
-
- if (banSlf4j) {
- configurations["compileClasspath"].apply {
- resolutionStrategy.componentSelection {
- withModule("org.slf4j:slf4j-api") {
- reject("No SLF4J allowed on compile classpath")
- }
- }
- }
- }
-
- tasks.named("check").configure {
- dependsOn("checkstyleMain", "checkstyleTest")
- }
-}
diff --git a/buildSrc/src/main/kotlin/LibsConfig.kt b/buildSrc/src/main/kotlin/LibsConfig.kt
deleted file mode 100644
index 90caecaba8..0000000000
--- a/buildSrc/src/main/kotlin/LibsConfig.kt
+++ /dev/null
@@ -1,214 +0,0 @@
-import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
-import org.gradle.api.Plugin
-import org.gradle.api.Project
-import org.gradle.api.artifacts.ExternalModuleDependency
-import org.gradle.api.artifacts.ModuleDependency
-import org.gradle.api.attributes.Bundling
-import org.gradle.api.attributes.Category
-import org.gradle.api.attributes.DocsType
-import org.gradle.api.attributes.LibraryElements
-import org.gradle.api.attributes.Usage
-import org.gradle.api.attributes.java.TargetJvmVersion
-import org.gradle.api.component.AdhocComponentWithVariants
-import org.gradle.api.component.SoftwareComponentFactory
-import org.gradle.api.publish.PublishingExtension
-import org.gradle.api.publish.maven.MavenPublication
-import org.gradle.api.tasks.bundling.Jar
-import org.gradle.kotlin.dsl.apply
-import org.gradle.kotlin.dsl.configure
-import org.gradle.kotlin.dsl.exclude
-import org.gradle.kotlin.dsl.get
-import org.gradle.kotlin.dsl.invoke
-import org.gradle.kotlin.dsl.named
-import org.gradle.kotlin.dsl.register
-import javax.inject.Inject
-
-fun Project.applyLibrariesConfiguration() {
- applyCommonConfiguration()
- apply(plugin = "java-base")
- apply(plugin = "maven-publish")
- apply(plugin = "com.github.johnrengelman.shadow")
- apply(plugin = "com.jfrog.artifactory")
-
- configurations {
- create("shade")
- }
-
- group = "${rootProject.group}.worldedit-libs"
-
- val relocations = mapOf(
- "net.kyori.text" to "com.sk89q.worldedit.util.formatting.text",
- "net.kyori.minecraft" to "com.sk89q.worldedit.util.kyori",
- )
-
- tasks.register("jar") {
- configurations = listOf(project.configurations["shade"])
- archiveClassifier.set("")
-
- // Yeet module-info's
- exclude("module-info.class")
-
- dependencies {
- exclude(dependency("com.google.guava:guava"))
- exclude(dependency("com.google.code.gson:gson"))
- exclude(dependency("com.google.errorprone:error_prone_annotations"))
- exclude(dependency("com.google.guava:failureaccess"))
- exclude(dependency("org.checkerframework:checker-qual"))
- exclude(dependency("org.jetbrains:annotations"))
- exclude(dependency("org.apache.logging.log4j:log4j-api"))
- exclude(dependency("com.google.code.findbugs:jsr305"))
- exclude {
- it.moduleGroup == "org.jetbrains.kotlin"
- }
- }
-
- relocations.forEach { (from, to) ->
- relocate(from, to)
- }
- }
- val altConfigFiles = { artifactType: String ->
- val deps = configurations["shade"].incoming.dependencies
- .filterIsInstance()
- .map { it.copy() }
- .map { dependency ->
- val category = dependency.attributes.getAttribute(Category.CATEGORY_ATTRIBUTE)?.name
- if (category == Category.REGULAR_PLATFORM || category == Category.ENFORCED_PLATFORM) {
- return@map dependency
- }
- try {
- dependency.artifact {
- name = dependency.name
- type = artifactType
- extension = "jar"
- classifier = artifactType
- }
- } catch (e: Exception) {
- throw RuntimeException("Failed to add artifact to dependency: $dependency", e)
- }
- dependency
- }
-
- files(configurations.detachedConfiguration(*deps.toTypedArray())
- .resolvedConfiguration.lenientConfiguration.artifacts
- .filter { it.classifier == artifactType }
- .map { zipTree(it.file) })
- }
- tasks.register("sourcesJar") {
- from({
- altConfigFiles("sources")
- })
-
- // Yeet module-info's
- exclude("module-info.java")
-
- relocations.forEach { (from, to) ->
- val filePattern = Regex("(.*)${from.replace('.', '/')}((?:/|$).*)")
- val textPattern = Regex.fromLiteral(from)
- eachFile {
- filter {
- it.replaceFirst(textPattern, to)
- }
- path = path.replaceFirst(filePattern, "$1${to.replace('.', '/')}$2")
- }
- }
- archiveClassifier.set("sources")
- }
-
- tasks.named("assemble").configure {
- dependsOn("jar", "sourcesJar")
- }
-
- project.apply()
-
- val libsComponent = project.components["libs"] as AdhocComponentWithVariants
-
- val apiElements = project.configurations.register("apiElements") {
- isVisible = false
- description = "API elements for libs"
- isCanBeResolved = false
- isCanBeConsumed = true
- attributes {
- attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_API))
- attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY))
- attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED))
- attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR))
- attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 16)
- }
- outgoing.artifact(tasks.named("jar"))
- }
-
- val runtimeElements = project.configurations.register("runtimeElements") {
- isVisible = false
- description = "Runtime elements for libs"
- isCanBeResolved = false
- isCanBeConsumed = true
- attributes {
- attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_RUNTIME))
- attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY))
- attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED))
- attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR))
- attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 16)
- }
- outgoing.artifact(tasks.named("jar"))
- }
-
- val sourcesElements = project.configurations.register("sourcesElements") {
- isVisible = false
- description = "Source elements for libs"
- isCanBeResolved = false
- isCanBeConsumed = true
- attributes {
- attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_RUNTIME))
- attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.DOCUMENTATION))
- attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED))
- attribute(DocsType.DOCS_TYPE_ATTRIBUTE, project.objects.named(DocsType.SOURCES))
- }
- outgoing.artifact(tasks.named("sourcesJar"))
- }
-
- libsComponent.addVariantsFromConfiguration(apiElements.get()) {
- mapToMavenScope("compile")
- }
-
- libsComponent.addVariantsFromConfiguration(runtimeElements.get()) {
- mapToMavenScope("runtime")
- }
-
- libsComponent.addVariantsFromConfiguration(sourcesElements.get()) {
- mapToMavenScope("runtime")
- }
-
- configure {
- publications {
- register("maven") {
- from(libsComponent)
- }
- }
- }
-
- applyCommonArtifactoryConfig()
-}
-
-// A horrible hack because `softwareComponentFactory` has to be gotten via plugin
-// gradle why
-internal open class LibsConfigPluginHack @Inject constructor(
- private val softwareComponentFactory: SoftwareComponentFactory
-) : Plugin {
- override fun apply(project: Project) {
- val libsComponents = softwareComponentFactory.adhoc("libs")
- project.components.add(libsComponents)
- }
-}
-
-fun Project.constrainDependenciesToLibsCore() {
- evaluationDependsOn(":worldedit-libs:core")
- val coreDeps = project(":worldedit-libs:core").configurations["shade"].dependencies
- .filterIsInstance()
- dependencies.constraints {
- for (coreDep in coreDeps) {
- add("shade", "${coreDep.group}:${coreDep.name}:${coreDep.version}") {
- because("libs should align with libs:core")
- }
- }
- }
-}
diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt
deleted file mode 100644
index 38f68d0101..0000000000
--- a/buildSrc/src/main/kotlin/PlatformConfig.kt
+++ /dev/null
@@ -1,98 +0,0 @@
-import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
-import org.gradle.api.Project
-import org.gradle.api.component.AdhocComponentWithVariants
-import org.gradle.api.publish.PublishingExtension
-import org.gradle.api.publish.maven.MavenPublication
-import org.gradle.api.tasks.bundling.Jar
-import org.gradle.kotlin.dsl.apply
-import org.gradle.kotlin.dsl.configure
-import org.gradle.kotlin.dsl.get
-import org.gradle.kotlin.dsl.named
-import org.gradle.kotlin.dsl.register
-import kotlin.collections.set
-
-fun Project.applyPlatformAndCoreConfiguration(javaRelease: Int = 21) {
- applyCommonConfiguration()
- apply(plugin = "java")
- apply(plugin = "maven-publish")
- apply(plugin = "com.jfrog.artifactory")
- applyCommonJavaConfiguration(
- sourcesJar = name in setOf("worldedit-core", "worldedit-bukkit", "worldedit-fabric"),
- javaRelease = javaRelease,
- banSlf4j = name !in setOf("worldedit-fabric", "worldedit-neoforge", "worldedit-sponge"),
- )
-
- ext["internalVersion"] = "$version+${rootProject.ext["gitCommitHash"]}"
-
- configure {
- publications {
- register("maven") {
- versionMapping {
- usage("java-api") {
- fromResolutionOf("runtimeClasspath")
- }
- usage("java-runtime") {
- fromResolutionResult()
- }
- }
- }
- }
- }
-
- applyCommonArtifactoryConfig()
-}
-
-fun Project.applyShadowConfiguration() {
- apply(plugin = "com.github.johnrengelman.shadow")
- tasks.named("shadowJar") {
- archiveClassifier.set("dist")
- dependencies {
- include(project(":worldedit-libs:core"))
- include(project(":worldedit-libs:${project.name.replace("worldedit-", "")}"))
- include(project(":worldedit-core"))
- exclude("com.google.code.findbugs:jsr305")
- }
- exclude("GradleStart**")
- exclude(".cache")
- exclude("LICENSE*")
- exclude("META-INF/maven/**")
- minimize()
- }
- val javaComponent = components["java"] as AdhocComponentWithVariants
- // I don't think we want this published (it's the shadow jar)
- javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
- skip()
- }
-}
-
-private val CLASSPATH = listOf("truezip", "truevfs", "js")
- .map { "$it.jar" }
- .flatMap { listOf(it, "WorldEdit/$it") }
- .joinToString(separator = " ")
-
-sealed class WorldEditKind(
- val name: String,
- val mainClass: String = "com.sk89q.worldedit.internal.util.InfoEntryPoint"
-) {
- class Standalone(mainClass: String) : WorldEditKind("STANDALONE", mainClass)
- object Mod : WorldEditKind("MOD")
- object Plugin : WorldEditKind("PLUGIN")
-}
-
-fun Project.addJarManifest(kind: WorldEditKind, includeClasspath: Boolean = false, extraAttributes: Map = mapOf()) {
- tasks.named("jar") {
- val version = project(":worldedit-core").version
- inputs.property("version", version)
- val attributes = mutableMapOf(
- "Implementation-Version" to version,
- "WorldEdit-Version" to version,
- "WorldEdit-Kind" to kind.name,
- "Main-Class" to kind.mainClass
- )
- if (includeClasspath) {
- attributes["Class-Path"] = CLASSPATH
- }
- attributes.putAll(extraAttributes)
- manifest.attributes(attributes)
- }
-}
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index d5400084c6..561dc42365 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,6 +1,9 @@
-[versions]
-neoGradle = "7.0.107"
+[plugins]
+codecov = "org.enginehub.codecov:0.2.0"
+neogradle-userdev = "net.neoforged.gradle.userdev:7.0.107"
+fabric-loom = "fabric-loom:1.6.9"
+[versions]
kyoriText = "3.0.4"
piston = "0.5.10"
autoValue = "1.10.4"
@@ -29,10 +32,8 @@ japicmp = "me.champeau.gradle:japicmp-gradle-plugin:0.4.2"
shadow = "com.github.johnrengelman:shadow:8.1.1"
jfrog-buildinfo = "org.jfrog.buildinfo:build-info-extractor-gradle:5.2.0"
-fabric-loom = "net.fabricmc:fabric-loom:1.6.9"
fabric-mixin = "net.fabricmc:sponge-mixin:0.13.3+mixin.0.8.5"
-codecov = "org.enginehub.gradle:gradle-codecov-plugin:0.2.0"
paperweight = "io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.6.0"
linBus-bom = "org.enginehub.lin-bus:lin-bus-bom:0.1.0-SNAPSHOT"
@@ -89,10 +90,6 @@ fastutil = "it.unimi.dsi:fastutil:8.5.12!!"
# may not be the same as the ones in the latest Bukkit API.
snakeyaml = "org.yaml:snakeyaml:2.0"
-[libraries.neoGradle-userdev]
-module = "net.neoforged.gradle:userdev"
-version.ref = "neoGradle"
-
[libraries.kyoriText-api]
module = "net.kyori:text-api"
version.ref = "kyoriText"
diff --git a/settings.gradle.kts b/settings.gradle.kts
index b5dc755413..4929a2ddfb 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1,10 +1,9 @@
pluginManagement {
repositories {
- mavenCentral()
gradlePluginPortal()
maven {
- name = "Fabric"
- url = uri("https://maven.fabricmc.net/")
+ name = "EngineHub"
+ url = uri("https://maven.enginehub.org/repo/")
}
}
}
@@ -12,8 +11,24 @@ plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}
+logger.lifecycle("""
+*******************************************
+ You are building WorldEdit!
+
+ If you encounter trouble:
+ 1) Read COMPILING.md if you haven't yet
+ 2) Try running 'build' in a separate Gradle run
+ 3) Use gradlew and not gradle
+ 4) If you still need help, ask on Discord! https://discord.gg/enginehub
+
+ Output files will be in [subproject]/build/libs
+*******************************************
+""")
+
rootProject.name = "worldedit"
+includeBuild("build-logic")
+
include("worldedit-libs")
listOf("1.19.4", "1.20", "1.20.2", "1.20.4", "1.20.5").forEach {
diff --git a/verification/build.gradle.kts b/verification/build.gradle.kts
index 0024ee1b16..e17ef62c81 100644
--- a/verification/build.gradle.kts
+++ b/verification/build.gradle.kts
@@ -74,6 +74,19 @@ for (projectFragment in listOf("bukkit", "cli", "core", "fabric", "neoforge")) {
(this as? ModuleDependency)?.isTransitive = false
}
)
+ val resolvedOldJar = files({
+ try {
+ conf.resolvedConfiguration.rethrowFailure()
+ conf
+ } catch (e: ResolveException) {
+ if (e.cause is ModuleVersionNotFoundException) {
+ logger.warn("Skipping check for $projectFragment API compatibility because there is no jar to compare against")
+ setOf()
+ } else {
+ throw e
+ }
+ }
+ })
val checkApi = tasks.register("check${capitalizedFragment}ApiCompatibility") {
group = "API Compatibility"
description = "Check API compatibility for $capitalizedFragment API"
@@ -89,20 +102,10 @@ for (projectFragment in listOf("bukkit", "cli", "core", "fabric", "neoforge")) {
onlyIf {
// Only check if we have a jar to compare against
- try {
- conf.resolvedConfiguration.rethrowFailure()
- true
- } catch (e: ResolveException) {
- if (e.cause is ModuleVersionNotFoundException) {
- it.logger.warn("Skipping check for $projectFragment API compatibility because there is no jar to compare against")
- false
- } else {
- throw e
- }
- }
+ !resolvedOldJar.isEmpty
}
- oldClasspath.from(conf)
+ oldClasspath.from(resolvedOldJar)
newClasspath.from(proj.tasks.named("jar"))
onlyModified.set(false)
failOnModification.set(false) // report does the failing (so we can accept)
diff --git a/worldedit-bukkit/adapters/adapter-1.18.2/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1.18.2/build.gradle.kts
deleted file mode 100644
index 7bb1cc7e95..0000000000
--- a/worldedit-bukkit/adapters/adapter-1.18.2/build.gradle.kts
+++ /dev/null
@@ -1,8 +0,0 @@
-import io.papermc.paperweight.userdev.PaperweightUserDependenciesExtension
-
-applyPaperweightAdapterConfiguration()
-
-dependencies {
- // https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
- the().paperDevBundle("1.18.2-R0.1-20220920.010157-167")
-}
diff --git a/worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightAdapter.java
deleted file mode 100644
index da5fc9c5d7..0000000000
--- a/worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightAdapter.java
+++ /dev/null
@@ -1,1061 +0,0 @@
-/*
- * WorldEdit, a Minecraft world manipulation toolkit
- * Copyright (C) sk89q
- * Copyright (C) WorldEdit team and contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.sk89q.worldedit.bukkit.adapter.impl.v1_18_R2;
-
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Sets;
-import com.google.common.util.concurrent.Futures;
-import com.mojang.datafixers.util.Either;
-import com.mojang.serialization.Lifecycle;
-import com.sk89q.worldedit.WorldEditException;
-import com.sk89q.worldedit.blocks.BaseItem;
-import com.sk89q.worldedit.blocks.BaseItemStack;
-import com.sk89q.worldedit.bukkit.BukkitAdapter;
-import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
-import com.sk89q.worldedit.bukkit.adapter.Refraction;
-import com.sk89q.worldedit.entity.BaseEntity;
-import com.sk89q.worldedit.extension.platform.Watchdog;
-import com.sk89q.worldedit.extent.Extent;
-import com.sk89q.worldedit.internal.Constants;
-import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
-import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
-import com.sk89q.worldedit.math.BlockVector2;
-import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.regions.Region;
-import com.sk89q.worldedit.registry.state.BooleanProperty;
-import com.sk89q.worldedit.registry.state.DirectionalProperty;
-import com.sk89q.worldedit.registry.state.EnumProperty;
-import com.sk89q.worldedit.registry.state.IntegerProperty;
-import com.sk89q.worldedit.registry.state.Property;
-import com.sk89q.worldedit.util.Direction;
-import com.sk89q.worldedit.util.SideEffect;
-import com.sk89q.worldedit.util.concurrency.LazyReference;
-import com.sk89q.worldedit.util.formatting.text.Component;
-import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
-import com.sk89q.worldedit.util.io.file.SafeFiles;
-import com.sk89q.worldedit.world.DataFixer;
-import com.sk89q.worldedit.world.RegenOptions;
-import com.sk89q.worldedit.world.biome.BiomeType;
-import com.sk89q.worldedit.world.biome.BiomeTypes;
-import com.sk89q.worldedit.world.block.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockState;
-import com.sk89q.worldedit.world.block.BlockStateHolder;
-import com.sk89q.worldedit.world.block.BlockType;
-import com.sk89q.worldedit.world.block.BlockTypes;
-import com.sk89q.worldedit.world.entity.EntityTypes;
-import com.sk89q.worldedit.world.item.ItemType;
-import net.minecraft.Util;
-import net.minecraft.core.BlockPos;
-import net.minecraft.core.Holder;
-import net.minecraft.core.Registry;
-import net.minecraft.nbt.ByteArrayTag;
-import net.minecraft.nbt.ByteTag;
-import net.minecraft.nbt.CompoundTag;
-import net.minecraft.nbt.DoubleTag;
-import net.minecraft.nbt.EndTag;
-import net.minecraft.nbt.FloatTag;
-import net.minecraft.nbt.IntArrayTag;
-import net.minecraft.nbt.IntTag;
-import net.minecraft.nbt.ListTag;
-import net.minecraft.nbt.LongArrayTag;
-import net.minecraft.nbt.LongTag;
-import net.minecraft.nbt.ShortTag;
-import net.minecraft.nbt.StringTag;
-import net.minecraft.nbt.Tag;
-import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
-import net.minecraft.network.protocol.game.ClientboundEntityEventPacket;
-import net.minecraft.resources.ResourceKey;
-import net.minecraft.resources.ResourceLocation;
-import net.minecraft.server.MinecraftServer;
-import net.minecraft.server.dedicated.DedicatedServer;
-import net.minecraft.server.level.ChunkHolder;
-import net.minecraft.server.level.ServerChunkCache;
-import net.minecraft.server.level.ServerLevel;
-import net.minecraft.server.level.progress.ChunkProgressListener;
-import net.minecraft.util.StringRepresentable;
-import net.minecraft.util.thread.BlockableEventLoop;
-import net.minecraft.world.Clearable;
-import net.minecraft.world.InteractionHand;
-import net.minecraft.world.InteractionResult;
-import net.minecraft.world.entity.Entity;
-import net.minecraft.world.entity.EntityType;
-import net.minecraft.world.item.Item;
-import net.minecraft.world.item.ItemStack;
-import net.minecraft.world.item.context.UseOnContext;
-import net.minecraft.world.level.ChunkPos;
-import net.minecraft.world.level.LevelSettings;
-import net.minecraft.world.level.biome.Biome;
-import net.minecraft.world.level.block.Block;
-import net.minecraft.world.level.block.Blocks;
-import net.minecraft.world.level.block.entity.BlockEntity;
-import net.minecraft.world.level.block.entity.StructureBlockEntity;
-import net.minecraft.world.level.block.state.StateDefinition;
-import net.minecraft.world.level.block.state.properties.DirectionProperty;
-import net.minecraft.world.level.chunk.ChunkAccess;
-import net.minecraft.world.level.chunk.ChunkStatus;
-import net.minecraft.world.level.chunk.LevelChunk;
-import net.minecraft.world.level.dimension.LevelStem;
-import net.minecraft.world.level.levelgen.WorldGenSettings;
-import net.minecraft.world.level.storage.LevelStorageSource;
-import net.minecraft.world.level.storage.PrimaryLevelData;
-import net.minecraft.world.phys.BlockHitResult;
-import net.minecraft.world.phys.Vec3;
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.World;
-import org.bukkit.World.Environment;
-import org.bukkit.block.data.BlockData;
-import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
-import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
-import org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData;
-import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity;
-import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
-import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
-import org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers;
-import org.bukkit.entity.Player;
-import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
-import org.bukkit.generator.ChunkGenerator;
-import org.enginehub.linbus.common.LinTagId;
-import org.enginehub.linbus.tree.LinByteArrayTag;
-import org.enginehub.linbus.tree.LinByteTag;
-import org.enginehub.linbus.tree.LinCompoundTag;
-import org.enginehub.linbus.tree.LinDoubleTag;
-import org.enginehub.linbus.tree.LinEndTag;
-import org.enginehub.linbus.tree.LinFloatTag;
-import org.enginehub.linbus.tree.LinIntArrayTag;
-import org.enginehub.linbus.tree.LinIntTag;
-import org.enginehub.linbus.tree.LinListTag;
-import org.enginehub.linbus.tree.LinLongArrayTag;
-import org.enginehub.linbus.tree.LinLongTag;
-import org.enginehub.linbus.tree.LinShortTag;
-import org.enginehub.linbus.tree.LinStringTag;
-import org.enginehub.linbus.tree.LinTag;
-import org.enginehub.linbus.tree.LinTagType;
-import org.spigotmc.SpigotConfig;
-import org.spigotmc.WatchdogThread;
-
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Objects;
-import java.util.OptionalInt;
-import java.util.OptionalLong;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ForkJoinPool;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.annotation.Nullable;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-public final class PaperweightAdapter implements BukkitImplAdapter {
-
- private final Logger logger = Logger.getLogger(getClass().getCanonicalName());
-
- private final Field serverWorldsField;
- private final Method getChunkFutureMethod;
- private final Field chunkProviderExecutorField;
- private final Watchdog watchdog;
-
- // ------------------------------------------------------------------------
- // Code that may break between versions of Minecraft
- // ------------------------------------------------------------------------
-
- public PaperweightAdapter() throws NoSuchFieldException, NoSuchMethodException {
- // A simple test
- CraftServer.class.cast(Bukkit.getServer());
-
- int dataVersion = CraftMagicNumbers.INSTANCE.getDataVersion();
- if (dataVersion != 2975) {
- throw new UnsupportedClassVersionError("Not 1.18.2!");
- }
-
- serverWorldsField = CraftServer.class.getDeclaredField("worlds");
- serverWorldsField.setAccessible(true);
-
- getChunkFutureMethod = ServerChunkCache.class.getDeclaredMethod(
- Refraction.pickName("getChunkFutureMainThread", "c"),
- int.class, int.class, ChunkStatus.class, boolean.class
- );
- getChunkFutureMethod.setAccessible(true);
-
- chunkProviderExecutorField = ServerChunkCache.class.getDeclaredField(
- Refraction.pickName("mainThreadProcessor", "g")
- );
- chunkProviderExecutorField.setAccessible(true);
-
- new PaperweightDataConverters(CraftMagicNumbers.INSTANCE.getDataVersion(), this).build(ForkJoinPool.commonPool());
-
- Watchdog watchdog;
- try {
- Class.forName("org.spigotmc.WatchdogThread");
- watchdog = new SpigotWatchdog();
- } catch (ClassNotFoundException | NoSuchFieldException e) {
- try {
- watchdog = new MojangWatchdog(((CraftServer) Bukkit.getServer()).getServer());
- } catch (NoSuchFieldException ex) {
- watchdog = null;
- }
- }
- this.watchdog = watchdog;
-
- try {
- Class.forName("org.spigotmc.SpigotConfig");
- SpigotConfig.config.set("world-settings.worldeditregentempworld.verbose", false);
- } catch (ClassNotFoundException ignored) {
- }
- }
-
- @Override
- public DataFixer getDataFixer() {
- return PaperweightDataConverters.INSTANCE;
- }
-
- /**
- * Read the given NBT data into the given tile entity.
- *
- * @param tileEntity the tile entity
- * @param tag the tag
- */
- static void readTagIntoTileEntity(CompoundTag tag, BlockEntity tileEntity) {
- tileEntity.load(tag);
- tileEntity.setChanged();
- }
-
- /**
- * Get the ID string of the given entity.
- *
- * @param entity the entity
- * @return the entity ID
- */
- private static String getEntityId(Entity entity) {
- return EntityType.getKey(entity.getType()).toString();
- }
-
- /**
- * Create an entity using the given entity ID.
- *
- * @param id the entity ID
- * @param world the world
- * @return an entity or null
- */
- @Nullable
- private static Entity createEntityFromId(String id, net.minecraft.world.level.Level world) {
- return EntityType.byString(id).map(t -> t.create(world)).orElse(null);
- }
-
- /**
- * Write the given NBT data into the given entity.
- *
- * @param entity the entity
- * @param tag the tag
- */
- private static void readTagIntoEntity(CompoundTag tag, Entity entity) {
- entity.load(tag);
- }
-
- /**
- * Write the entity's NBT data to the given tag.
- *
- * @param entity the entity
- * @param tag the tag
- */
- private static void readEntityIntoTag(Entity entity, CompoundTag tag) {
- entity.save(tag);
- }
-
- private static Block getBlockFromType(BlockType blockType) {
- return Registry.BLOCK.get(ResourceLocation.tryParse(blockType.id()));
- }
-
- private static Item getItemFromType(ItemType itemType) {
- return Registry.ITEM.get(ResourceLocation.tryParse(itemType.id()));
- }
-
- @Override
- public OptionalInt getInternalBlockStateId(BlockData data) {
- net.minecraft.world.level.block.state.BlockState state = ((CraftBlockData) data).getState();
- int combinedId = Block.getId(state);
- return combinedId == 0 && state.getBlock() != Blocks.AIR ? OptionalInt.empty() : OptionalInt.of(combinedId);
- }
-
- @Override
- public OptionalInt getInternalBlockStateId(BlockState state) {
- Block mcBlock = getBlockFromType(state.getBlockType());
- net.minecraft.world.level.block.state.BlockState newState = mcBlock.defaultBlockState();
- Map, Object> states = state.getStates();
- newState = applyProperties(mcBlock.getStateDefinition(), newState, states);
- final int combinedId = Block.getId(newState);
- return combinedId == 0 && state.getBlockType() != BlockTypes.AIR ? OptionalInt.empty() : OptionalInt.of(combinedId);
- }
-
- @Override
- public BlockState getBlock(Location location) {
- checkNotNull(location);
-
- CraftWorld craftWorld = ((CraftWorld) location.getWorld());
- int x = location.getBlockX();
- int y = location.getBlockY();
- int z = location.getBlockZ();
-
- final ServerLevel handle = craftWorld.getHandle();
- LevelChunk chunk = handle.getChunk(x >> 4, z >> 4);
- final BlockPos blockPos = new BlockPos(x, y, z);
- final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(blockPos);
- int internalId = Block.getId(blockData);
- BlockState state = BlockStateIdAccess.getBlockStateById(internalId);
- if (state == null) {
- org.bukkit.block.Block bukkitBlock = location.getBlock();
- state = BukkitAdapter.adapt(bukkitBlock.getBlockData());
- }
-
- return state;
- }
-
- @Override
- public BaseBlock getFullBlock(Location location) {
- BlockState state = getBlock(location);
-
- CraftWorld craftWorld = ((CraftWorld) location.getWorld());
- int x = location.getBlockX();
- int y = location.getBlockY();
- int z = location.getBlockZ();
-
- final ServerLevel handle = craftWorld.getHandle();
- LevelChunk chunk = handle.getChunk(x >> 4, z >> 4);
- final BlockPos blockPos = new BlockPos(x, y, z);
-
- // Read the NBT data
- BlockEntity te = chunk.getBlockEntity(blockPos);
- if (te != null) {
- CompoundTag tag = te.saveWithId();
- return state.toBaseBlock(LazyReference.from(() -> (LinCompoundTag) toNative(tag)));
- }
-
- return state.toBaseBlock();
- }
-
- private static final HashMap> biomeTypeToNMSCache = new HashMap<>();
- private static final HashMap, BiomeType> biomeTypeFromNMSCache = new HashMap<>();
-
- @Override
- public BiomeType getBiome(Location location) {
- checkNotNull(location);
-
- CraftWorld craftWorld = ((CraftWorld) location.getWorld());
- int x = location.getBlockX();
- int y = location.getBlockY();
- int z = location.getBlockZ();
-
- final ServerLevel handle = craftWorld.getHandle();
- LevelChunk chunk = handle.getChunk(x >> 4, z >> 4);
-
- return biomeTypeFromNMSCache.computeIfAbsent(chunk.getNoiseBiome(x >> 2, y >> 2, z >> 2), b -> BiomeType.REGISTRY.get(b.unwrapKey().get().location().toString()));
- }
-
- @Override
- public void setBiome(Location location, BiomeType biome) {
- checkNotNull(location);
- checkNotNull(biome);
-
- CraftWorld craftWorld = ((CraftWorld) location.getWorld());
- int x = location.getBlockX();
- int y = location.getBlockY();
- int z = location.getBlockZ();
-
- final ServerLevel handle = craftWorld.getHandle();
- LevelChunk chunk = handle.getChunk(x >> 4, z >> 4);
- chunk.setBiome(x >> 2, y >> 2, z >> 2, biomeTypeToNMSCache.computeIfAbsent(biome, b -> ((CraftServer) Bukkit.getServer()).getServer().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getHolderOrThrow(ResourceKey.create(Registry.BIOME_REGISTRY, new ResourceLocation(b.id())))));
- chunk.setUnsaved(true);
- }
-
- @Override
- public WorldNativeAccess, ?, ?> createWorldNativeAccess(World world) {
- return new PaperweightWorldNativeAccess(this,
- new WeakReference<>(((CraftWorld) world).getHandle()));
- }
-
- private static net.minecraft.core.Direction adapt(Direction face) {
- switch (face) {
- case NORTH:
- return net.minecraft.core.Direction.NORTH;
- case SOUTH:
- return net.minecraft.core.Direction.SOUTH;
- case WEST:
- return net.minecraft.core.Direction.WEST;
- case EAST:
- return net.minecraft.core.Direction.EAST;
- case DOWN:
- return net.minecraft.core.Direction.DOWN;
- case UP:
- default:
- return net.minecraft.core.Direction.UP;
- }
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- private net.minecraft.world.level.block.state.BlockState applyProperties(
- StateDefinition stateContainer,
- net.minecraft.world.level.block.state.BlockState newState,
- Map, Object> states
- ) {
- for (Map.Entry, Object> state : states.entrySet()) {
- net.minecraft.world.level.block.state.properties.Property> property =
- stateContainer.getProperty(state.getKey().getName());
- Comparable> value = (Comparable) state.getValue();
- // we may need to adapt this value, depending on the source prop
- if (property instanceof DirectionProperty) {
- Direction dir = (Direction) value;
- value = adapt(dir);
- } else if (property instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
- String enumName = (String) value;
- value = ((net.minecraft.world.level.block.state.properties.EnumProperty>) property)
- .getValue(enumName).orElseThrow(() ->
- new IllegalStateException(
- "Enum property " + property.getName() + " does not contain " + enumName
- )
- );
- }
-
- newState = newState.setValue(
- (net.minecraft.world.level.block.state.properties.Property) property,
- (Comparable) value
- );
- }
- return newState;
- }
-
- @Override
- public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
- checkNotNull(entity);
-
- CraftEntity craftEntity = ((CraftEntity) entity);
- Entity mcEntity = craftEntity.getHandle();
-
- // Do not allow creating of passenger entity snapshots, passengers are included in the vehicle entity
- if (mcEntity.isPassenger()) {
- return null;
- }
-
- String id = getEntityId(mcEntity);
-
- CompoundTag tag = new CompoundTag();
- readEntityIntoTag(mcEntity, tag);
- return new BaseEntity(
- EntityTypes.get(id),
- LazyReference.from(() -> (LinCompoundTag) toNative(tag))
- );
- }
-
- @Nullable
- @Override
- public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state) {
- checkNotNull(location);
- checkNotNull(state);
-
- CraftWorld craftWorld = ((CraftWorld) location.getWorld());
- ServerLevel worldServer = craftWorld.getHandle();
-
- String entityId = state.getType().id();
-
- LinCompoundTag nativeTag = state.getNbt();
- CompoundTag tag;
- if (nativeTag != null) {
- tag = (CompoundTag) fromNative(nativeTag);
- removeUnwantedEntityTagsRecursively(tag);
- } else {
- tag = new CompoundTag();
- }
-
- tag.putString("id", entityId);
-
- Entity createdEntity = EntityType.loadEntityRecursive(tag, craftWorld.getHandle(), (loadedEntity) -> {
- loadedEntity.absMoveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
- return loadedEntity;
- });
-
- if (createdEntity != null) {
- worldServer.addFreshEntityWithPassengers(createdEntity, SpawnReason.CUSTOM);
- return createdEntity.getBukkitEntity();
- } else {
- return null;
- }
- }
-
- // This removes all unwanted tags from the main entity and all its passengers
- private void removeUnwantedEntityTagsRecursively(CompoundTag tag) {
- for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
- tag.remove(name);
- }
-
- // Adapted from net.minecraft.world.entity.EntityType#loadEntityRecursive
- if (tag.contains("Passengers", LinTagId.LIST.id())) {
- ListTag nbttaglist = tag.getList("Passengers", LinTagId.COMPOUND.id());
-
- for (int i = 0; i < nbttaglist.size(); ++i) {
- removeUnwantedEntityTagsRecursively(nbttaglist.getCompound(i));
- }
- }
- }
-
- @Override
- public Component getRichBlockName(BlockType blockType) {
- return TranslatableComponent.of(getBlockFromType(blockType).getDescriptionId());
- }
-
- @Override
- public Component getRichItemName(ItemType itemType) {
- return TranslatableComponent.of(getItemFromType(itemType).getDescriptionId());
- }
-
- @Override
- public Component getRichItemName(BaseItemStack itemStack) {
- return TranslatableComponent.of(CraftItemStack.asNMSCopy(BukkitAdapter.adapt(itemStack)).getDescriptionId());
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private static final LoadingCache> PROPERTY_CACHE = CacheBuilder.newBuilder().build(new CacheLoader>() {
- @Override
- public Property> load(net.minecraft.world.level.block.state.properties.Property state) throws Exception {
- if (state instanceof net.minecraft.world.level.block.state.properties.BooleanProperty) {
- return new BooleanProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
- } else if (state instanceof DirectionProperty) {
- return new DirectionalProperty(state.getName(),
- (List) state.getPossibleValues().stream().map(e -> Direction.valueOf(((StringRepresentable) e).getSerializedName().toUpperCase(Locale.ROOT))).toList());
- } else if (state instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
- return new EnumProperty(state.getName(),
- (List) state.getPossibleValues().stream().map(e -> ((StringRepresentable) e).getSerializedName()).toList());
- } else if (state instanceof net.minecraft.world.level.block.state.properties.IntegerProperty) {
- return new IntegerProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
- } else {
- throw new IllegalArgumentException("WorldEdit needs an update to support " + state.getClass().getSimpleName());
- }
- }
- });
-
- @SuppressWarnings({ "rawtypes" })
- @Override
- public Map> getProperties(BlockType blockType) {
- Map> properties = new TreeMap<>();
- Block block = getBlockFromType(blockType);
- StateDefinition blockStateList =
- block.getStateDefinition();
- for (net.minecraft.world.level.block.state.properties.Property state : blockStateList.getProperties()) {
- Property> property = PROPERTY_CACHE.getUnchecked(state);
- properties.put(property.getName(), property);
- }
- return properties;
- }
-
- @Override
- public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData) {
- ((CraftPlayer) player).getHandle().networkManager.send(ClientboundBlockEntityDataPacket.create(
- new StructureBlockEntity(
- new BlockPos(pos.x(), pos.y(), pos.z()),
- Blocks.STRUCTURE_BLOCK.defaultBlockState()
- ),
- __ -> (CompoundTag) fromNative(nbtData)
- ));
- }
-
- @Override
- public void sendFakeOP(Player player) {
- ((CraftPlayer) player).getHandle().networkManager.send(new ClientboundEntityEventPacket(
- ((CraftPlayer) player).getHandle(), (byte) 28
- ));
- }
-
- @Override
- public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
- ItemStack stack = new ItemStack(Registry.ITEM.get(ResourceLocation.tryParse(item.getType().id())), item.getAmount());
- stack.setTag(((CompoundTag) fromNative(item.getNbt())));
- return CraftItemStack.asCraftMirror(stack);
- }
-
- @Override
- public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) {
- final ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
- final BaseItemStack weStack = new BaseItemStack(BukkitAdapter.asItemType(itemStack.getType()), itemStack.getAmount());
- weStack.setNbtReference(LazyReference.from(() -> (LinCompoundTag) toNative(nmsStack.getTag())));
- return weStack;
- }
-
- private final LoadingCache fakePlayers
- = CacheBuilder.newBuilder().weakKeys().softValues().build(CacheLoader.from(PaperweightFakePlayer::new));
-
- @Override
- public boolean simulateItemUse(World world, BlockVector3 position, BaseItem item, Direction face) {
- CraftWorld craftWorld = (CraftWorld) world;
- ServerLevel worldServer = craftWorld.getHandle();
- ItemStack stack = CraftItemStack.asNMSCopy(BukkitAdapter.adapt(item instanceof BaseItemStack
- ? ((BaseItemStack) item) : new BaseItemStack(item.getType(), item.getNbtReference(), 1)));
- stack.setTag((CompoundTag) fromNative(item.getNbt()));
-
- PaperweightFakePlayer fakePlayer;
- try {
- fakePlayer = fakePlayers.get(worldServer);
- } catch (ExecutionException ignored) {
- return false;
- }
- fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, stack);
- fakePlayer.absMoveTo(position.x(), position.y(), position.z(),
- (float) face.toVector().toYaw(), (float) face.toVector().toPitch());
-
- final BlockPos blockPos = new BlockPos(position.x(), position.y(), position.z());
- final Vec3 blockVec = Vec3.atLowerCornerOf(blockPos);
- final net.minecraft.core.Direction enumFacing = adapt(face);
- BlockHitResult rayTrace = new BlockHitResult(blockVec, enumFacing, blockPos, false);
- UseOnContext context = new UseOnContext(fakePlayer, InteractionHand.MAIN_HAND, rayTrace);
- InteractionResult result = stack.useOn(context, InteractionHand.MAIN_HAND);
- if (result != InteractionResult.SUCCESS) {
- if (worldServer.getBlockState(blockPos).use(worldServer, fakePlayer, InteractionHand.MAIN_HAND, rayTrace).consumesAction()) {
- result = InteractionResult.SUCCESS;
- } else {
- result = stack.getItem().use(worldServer, fakePlayer, InteractionHand.MAIN_HAND).getResult();
- }
- }
-
- return result == InteractionResult.SUCCESS;
- }
-
- @Override
- public boolean canPlaceAt(World world, BlockVector3 position, BlockState blockState) {
- int internalId = BlockStateIdAccess.getBlockStateId(blockState);
- net.minecraft.world.level.block.state.BlockState blockData = Block.stateById(internalId);
- return blockData.canSurvive(((CraftWorld) world).getHandle(), new BlockPos(position.x(), position.y(), position.z()));
- }
-
- @Override
- public boolean regenerate(World bukkitWorld, Region region, Extent extent, RegenOptions options) {
- try {
- doRegen(bukkitWorld, region, extent, options);
- } catch (Exception e) {
- throw new IllegalStateException("Regen failed.", e);
- }
-
- return true;
- }
-
- private void doRegen(World bukkitWorld, Region region, Extent extent, RegenOptions options) throws Exception {
- Environment env = bukkitWorld.getEnvironment();
- ChunkGenerator gen = bukkitWorld.getGenerator();
-
- Path tempDir = Files.createTempDirectory("WorldEditWorldGen");
- LevelStorageSource levelStorage = LevelStorageSource.createDefault(tempDir);
- ResourceKey worldDimKey = getWorldDimKey(env);
- try (LevelStorageSource.LevelStorageAccess session = levelStorage.createAccess("worldeditregentempworld", worldDimKey)) {
- ServerLevel originalWorld = ((CraftWorld) bukkitWorld).getHandle();
- PrimaryLevelData levelProperties = (PrimaryLevelData) originalWorld.getServer()
- .getWorldData().overworldData();
- WorldGenSettings originalOpts = levelProperties.worldGenSettings();
-
- long seed = options.getSeed().orElse(originalWorld.getSeed());
- WorldGenSettings newOpts = options.getSeed().isPresent()
- ? originalOpts.withSeed(levelProperties.isHardcore(), OptionalLong.of(seed))
- : originalOpts;
-
- LevelSettings newWorldSettings = new LevelSettings(
- "worldeditregentempworld",
- levelProperties.settings.gameType(),
- levelProperties.settings.hardcore(),
- levelProperties.settings.difficulty(),
- levelProperties.settings.allowCommands(),
- levelProperties.settings.gameRules(),
- levelProperties.settings.getDataPackConfig()
- );
- PrimaryLevelData newWorldData = new PrimaryLevelData(newWorldSettings, newOpts, Lifecycle.stable());
-
- ServerLevel freshWorld = new ServerLevel(
- originalWorld.getServer(),
- originalWorld.getServer().executor,
- session, newWorldData,
- originalWorld.dimension(),
- originalWorld.dimensionTypeRegistration(),
- new NoOpWorldLoadListener(),
- newOpts.dimensions().get(worldDimKey).generator(),
- originalWorld.isDebug(),
- seed,
- ImmutableList.of(),
- false,
- env, gen,
- bukkitWorld.getBiomeProvider()
- );
- try {
- regenForWorld(region, extent, freshWorld, options);
- } finally {
- freshWorld.getChunkSource().close(false);
- }
- } finally {
- try {
- @SuppressWarnings("unchecked")
- Map map = (Map) serverWorldsField.get(Bukkit.getServer());
- map.remove("worldeditregentempworld");
- } catch (IllegalAccessException ignored) {
- }
- SafeFiles.tryHardToDeleteDir(tempDir);
- }
- }
-
- private BiomeType adapt(ServerLevel serverWorld, Biome origBiome) {
- ResourceLocation key = serverWorld.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getKey(origBiome);
- if (key == null) {
- return null;
- }
- return BiomeTypes.get(key.toString());
- }
-
- @SuppressWarnings("unchecked")
- private void regenForWorld(Region region, Extent extent, ServerLevel serverWorld, RegenOptions options) throws WorldEditException {
- List> chunkLoadings = submitChunkLoadTasks(region, serverWorld);
- BlockableEventLoop executor;
- try {
- executor = (BlockableEventLoop) chunkProviderExecutorField.get(serverWorld.getChunkSource());
- } catch (IllegalAccessException e) {
- throw new IllegalStateException("Couldn't get executor for chunk loading.", e);
- }
- executor.managedBlock(() -> {
- // bail out early if a future fails
- if (chunkLoadings.stream().anyMatch(ftr ->
- ftr.isDone() && Futures.getUnchecked(ftr) == null
- )) {
- return false;
- }
- return chunkLoadings.stream().allMatch(CompletableFuture::isDone);
- });
- Map chunks = new HashMap<>();
- for (CompletableFuture future : chunkLoadings) {
- @Nullable
- ChunkAccess chunk = future.getNow(null);
- checkState(chunk != null, "Failed to generate a chunk, regen failed.");
- chunks.put(chunk.getPos(), chunk);
- }
-
- for (BlockVector3 vec : region) {
- BlockPos pos = new BlockPos(vec.x(), vec.y(), vec.z());
- ChunkAccess chunk = chunks.get(new ChunkPos(pos));
- final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(pos);
- int internalId = Block.getId(blockData);
- BlockStateHolder> state = BlockStateIdAccess.getBlockStateById(internalId);
- Objects.requireNonNull(state);
- BlockEntity blockEntity = chunk.getBlockEntity(pos);
- if (blockEntity != null) {
- CompoundTag tag = blockEntity.saveWithId();
- state = state.toBaseBlock(LazyReference.from(() -> (LinCompoundTag) toNative(tag)));
- }
- extent.setBlock(vec, state.toBaseBlock());
- if (options.shouldRegenBiomes()) {
- Biome origBiome = chunk.getNoiseBiome(vec.x(), vec.y(), vec.z()).value();
- BiomeType adaptedBiome = adapt(serverWorld, origBiome);
- if (adaptedBiome != null) {
- extent.setBiome(vec, adaptedBiome);
- }
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- private List> submitChunkLoadTasks(Region region, ServerLevel serverWorld) {
- ServerChunkCache chunkManager = serverWorld.getChunkSource();
- List> chunkLoadings = new ArrayList<>();
- // Pre-gen all the chunks
- for (BlockVector2 chunk : region.getChunks()) {
- try {
- //noinspection unchecked
- chunkLoadings.add(
- ((CompletableFuture>)
- getChunkFutureMethod.invoke(chunkManager, chunk.x(), chunk.z(), ChunkStatus.FEATURES, true))
- .thenApply(either -> either.left().orElse(null))
- );
- } catch (IllegalAccessException | InvocationTargetException e) {
- throw new IllegalStateException("Couldn't load chunk for regen.", e);
- }
- }
- return chunkLoadings;
- }
-
- private ResourceKey getWorldDimKey(Environment env) {
- switch (env) {
- case NETHER:
- return LevelStem.NETHER;
- case THE_END:
- return LevelStem.END;
- case NORMAL:
- default:
- return LevelStem.OVERWORLD;
- }
- }
-
- private static final Set SUPPORTED_SIDE_EFFECTS = Sets.immutableEnumSet(
- SideEffect.NEIGHBORS,
- SideEffect.LIGHTING,
- SideEffect.VALIDATION,
- SideEffect.ENTITY_AI,
- SideEffect.EVENTS,
- SideEffect.UPDATE
- );
-
- @Override
- public Set getSupportedSideEffects() {
- return SUPPORTED_SIDE_EFFECTS;
- }
-
- @Override
- public boolean clearContainerBlockContents(World world, BlockVector3 pt) {
- ServerLevel originalWorld = ((CraftWorld) world).getHandle();
-
- BlockEntity entity = originalWorld.getBlockEntity(new BlockPos(pt.x(), pt.y(), pt.z()));
- if (entity instanceof Clearable) {
- ((Clearable) entity).clearContent();
- return true;
- }
- return false;
- }
-
- @Override
- public void initializeRegistries() {
- DedicatedServer server = ((CraftServer) Bukkit.getServer()).getServer();
- // Biomes
- for (ResourceLocation name : server.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).keySet()) {
- if (BiomeType.REGISTRY.get(name.toString()) == null) {
- BiomeType.REGISTRY.register(name.toString(), new BiomeType(name.toString()));
- }
- }
- }
-
- // ------------------------------------------------------------------------
- // Code that is less likely to break
- // ------------------------------------------------------------------------
-
- /**
- * Converts from a non-native NMS NBT structure to a native WorldEdit NBT
- * structure.
- *
- * @param foreign non-native NMS NBT structure
- * @return native WorldEdit NBT structure
- */
- LinTag> toNative(Tag foreign) {
- if (foreign == null) {
- return null;
- }
- if (foreign instanceof CompoundTag compoundTag) {
- LinCompoundTag.Builder builder = LinCompoundTag.builder();
- for (var entry : compoundTag.tags.entrySet()) {
- builder.put(entry.getKey(), toNative(entry.getValue()));
- }
- return builder.build();
- } else if (foreign instanceof ByteTag byteTag) {
- return LinByteTag.of(byteTag.getAsByte());
- } else if (foreign instanceof ByteArrayTag byteArrayTag) {
- return LinByteArrayTag.of(byteArrayTag.getAsByteArray());
- } else if (foreign instanceof DoubleTag doubleTag) {
- return LinDoubleTag.of(doubleTag.getAsDouble());
- } else if (foreign instanceof FloatTag floatTag) {
- return LinFloatTag.of(floatTag.getAsFloat());
- } else if (foreign instanceof IntTag intTag) {
- return LinIntTag.of(intTag.getAsInt());
- } else if (foreign instanceof IntArrayTag intArrayTag) {
- return LinIntArrayTag.of(intArrayTag.getAsIntArray());
- } else if (foreign instanceof LongArrayTag longArrayTag) {
- return LinLongArrayTag.of(longArrayTag.getAsLongArray());
- } else if (foreign instanceof ListTag listTag) {
- try {
- return toNativeList(listTag);
- } catch (Throwable e) {
- logger.log(Level.WARNING, "Failed to convert net.minecraft.nbt.ListTag", e);
- return LinListTag.empty(LinTagType.endTag());
- }
- } else if (foreign instanceof LongTag longTag) {
- return LinLongTag.of(longTag.getAsLong());
- } else if (foreign instanceof ShortTag shortTag) {
- return LinShortTag.of(shortTag.getAsShort());
- } else if (foreign instanceof StringTag stringTag) {
- return LinStringTag.of(stringTag.getAsString());
- } else if (foreign instanceof EndTag) {
- return LinEndTag.instance();
- } else {
- throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName());
- }
- }
-
- /**
- * Convert a foreign NBT list tag into a native WorldEdit one.
- *
- * @param foreign the foreign tag
- * @return the converted tag
- * @throws SecurityException on error
- * @throws IllegalArgumentException on error
- */
- private LinListTag> toNativeList(ListTag foreign) throws SecurityException, IllegalArgumentException {
- LinListTag.Builder> builder = LinListTag.builder(
- LinTagType.fromId(LinTagId.fromId(foreign.getElementType()))
- );
-
- for (Tag tag : foreign) {
- builder.add(toNative(tag));
- }
-
- return builder.build();
- }
-
- /**
- * Converts a WorldEdit-native NBT structure to a NMS structure.
- *
- * @param foreign structure to convert
- * @return non-native structure
- */
- Tag fromNative(LinTag> foreign) {
- if (foreign == null) {
- return null;
- }
- if (foreign instanceof LinCompoundTag compoundTag) {
- CompoundTag tag = new CompoundTag();
- for (var entry : compoundTag.value().entrySet()) {
- tag.put(entry.getKey(), fromNative(entry.getValue()));
- }
- return tag;
- } else if (foreign instanceof LinByteTag byteTag) {
- return ByteTag.valueOf(byteTag.valueAsByte());
- } else if (foreign instanceof LinByteArrayTag byteArrayTag) {
- return new ByteArrayTag(byteArrayTag.value());
- } else if (foreign instanceof LinDoubleTag doubleTag) {
- return DoubleTag.valueOf(doubleTag.valueAsDouble());
- } else if (foreign instanceof LinFloatTag floatTag) {
- return FloatTag.valueOf(floatTag.valueAsFloat());
- } else if (foreign instanceof LinIntTag intTag) {
- return IntTag.valueOf(intTag.valueAsInt());
- } else if (foreign instanceof LinIntArrayTag intArrayTag) {
- return new IntArrayTag(intArrayTag.value());
- } else if (foreign instanceof LinLongArrayTag longArrayTag) {
- return new LongArrayTag(longArrayTag.value());
- } else if (foreign instanceof LinListTag> listTag) {
- ListTag tag = new ListTag();
- for (var t : listTag.value()) {
- tag.add(fromNative(t));
- }
- return tag;
- } else if (foreign instanceof LinLongTag longTag) {
- return LongTag.valueOf(longTag.valueAsLong());
- } else if (foreign instanceof LinShortTag shortTag) {
- return ShortTag.valueOf(shortTag.valueAsShort());
- } else if (foreign instanceof LinStringTag stringTag) {
- return StringTag.valueOf(stringTag.value());
- } else if (foreign instanceof LinEndTag) {
- return EndTag.INSTANCE;
- } else {
- throw new IllegalArgumentException("Don't know how to make NMS " + foreign.getClass().getCanonicalName());
- }
- }
-
- @Override
- public boolean supportsWatchdog() {
- return watchdog != null;
- }
-
- @Override
- public void tickWatchdog() {
- watchdog.tick();
- }
-
- private class SpigotWatchdog implements Watchdog {
- private final Field instanceField;
- private final Field lastTickField;
-
- SpigotWatchdog() throws NoSuchFieldException {
- Field instanceField = WatchdogThread.class.getDeclaredField("instance");
- instanceField.setAccessible(true);
- this.instanceField = instanceField;
-
- Field lastTickField = WatchdogThread.class.getDeclaredField("lastTick");
- lastTickField.setAccessible(true);
- this.lastTickField = lastTickField;
- }
-
- @Override
- public void tick() {
- try {
- WatchdogThread instance = (WatchdogThread) this.instanceField.get(null);
- if ((long) lastTickField.get(instance) != 0) {
- WatchdogThread.tick();
- }
- } catch (IllegalAccessException e) {
- logger.log(Level.WARNING, "Failed to tick watchdog", e);
- }
- }
- }
-
- private static class MojangWatchdog implements Watchdog {
- private final DedicatedServer server;
- private final Field tickField;
-
- MojangWatchdog(DedicatedServer server) throws NoSuchFieldException {
- this.server = server;
- Field tickField = MinecraftServer.class.getDeclaredField(
- Refraction.pickName("nextTickTime", "ao")
- );
- tickField.setAccessible(true);
- this.tickField = tickField;
- }
-
- @Override
- public void tick() {
- try {
- tickField.set(server, Util.getMillis());
- } catch (IllegalAccessException ignored) {
- }
- }
- }
-
- private static class NoOpWorldLoadListener implements ChunkProgressListener {
- @Override
- public void updateSpawnPos(ChunkPos spawnPos) {
- }
-
- @Override
- public void onStatusChange(ChunkPos pos, @org.jetbrains.annotations.Nullable ChunkStatus status) {
- }
-
- @Override
- public void start() {
- }
-
- @Override
- public void stop() {
- }
-
- @Override
- public void setChunkRadius(int radius) {
- }
- }
-}
diff --git a/worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightDataConverters.java b/worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightDataConverters.java
deleted file mode 100644
index 78d4e2fa45..0000000000
--- a/worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightDataConverters.java
+++ /dev/null
@@ -1,2800 +0,0 @@
-/*
- * WorldEdit, a Minecraft world manipulation toolkit
- * Copyright (C) sk89q
- * Copyright (C) WorldEdit team and contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.sk89q.worldedit.bukkit.adapter.impl.v1_18_R2;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-import com.mojang.datafixers.DSL.TypeReference;
-import com.mojang.datafixers.DataFixer;
-import com.mojang.datafixers.DataFixerBuilder;
-import com.mojang.datafixers.schemas.Schema;
-import com.mojang.serialization.Dynamic;
-import net.minecraft.core.Direction;
-import net.minecraft.nbt.CompoundTag;
-import net.minecraft.nbt.FloatTag;
-import net.minecraft.nbt.ListTag;
-import net.minecraft.nbt.NbtOps;
-import net.minecraft.nbt.StringTag;
-import net.minecraft.nbt.Tag;
-import net.minecraft.network.chat.Component;
-import net.minecraft.network.chat.MutableComponent;
-import net.minecraft.network.chat.TextComponent;
-import net.minecraft.resources.ResourceLocation;
-import net.minecraft.util.GsonHelper;
-import net.minecraft.util.StringUtil;
-import net.minecraft.util.datafix.DataFixers;
-import net.minecraft.util.datafix.fixes.References;
-import net.minecraft.world.item.DyeColor;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.enginehub.linbus.tree.LinCompoundTag;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.Executor;
-import java.util.stream.Collectors;
-import javax.annotation.Nullable;
-
-/**
- * Handles converting all Pre 1.13.2 data using the Legacy DataFix System (ported to 1.13.2)
- *
- * We register a DFU Fixer per Legacy Data Version and apply the fixes using legacy strategy
- * which is safer, faster and cleaner code.
- *
- * The pre DFU code did not fail when the Source version was unknown.
- *
- * This class also provides util methods for converting compounds to wrap the update call to
- * receive the source version in the compound
- */
-@SuppressWarnings({ "rawtypes", "unchecked" })
-class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.worldedit.world.DataFixer {
-
- @SuppressWarnings("unchecked")
- @Override
- public T fixUp(FixType type, T original, int srcVer) {
- if (type == FixTypes.CHUNK) {
- return (T) fixChunk((LinCompoundTag) original, srcVer);
- } else if (type == FixTypes.BLOCK_ENTITY) {
- return (T) fixBlockEntity((LinCompoundTag) original, srcVer);
- } else if (type == FixTypes.ENTITY) {
- return (T) fixEntity((LinCompoundTag) original, srcVer);
- } else if (type == FixTypes.BLOCK_STATE) {
- return (T) fixBlockState((String) original, srcVer);
- } else if (type == FixTypes.ITEM_TYPE) {
- return (T) fixItemType((String) original, srcVer);
- } else if (type == FixTypes.BIOME) {
- return (T) fixBiome((String) original, srcVer);
- }
- return original;
- }
-
- private LinCompoundTag fixChunk(LinCompoundTag originalChunk, int srcVer) {
- CompoundTag tag = (CompoundTag) adapter.fromNative(originalChunk);
- CompoundTag fixed = convert(LegacyType.CHUNK, tag, srcVer);
- return (LinCompoundTag) adapter.toNative(fixed);
- }
-
- private LinCompoundTag fixBlockEntity(LinCompoundTag origTileEnt, int srcVer) {
- CompoundTag tag = (CompoundTag) adapter.fromNative(origTileEnt);
- CompoundTag fixed = convert(LegacyType.BLOCK_ENTITY, tag, srcVer);
- return (LinCompoundTag) adapter.toNative(fixed);
- }
-
- private LinCompoundTag fixEntity(LinCompoundTag origEnt, int srcVer) {
- CompoundTag tag = (CompoundTag) adapter.fromNative(origEnt);
- CompoundTag fixed = convert(LegacyType.ENTITY, tag, srcVer);
- return (LinCompoundTag) adapter.toNative(fixed);
- }
-
- private String fixBlockState(String blockState, int srcVer) {
- CompoundTag stateNBT = stateToNBT(blockState);
- Dynamic dynamic = new Dynamic<>(OPS_NBT, stateNBT);
- CompoundTag fixed = (CompoundTag) INSTANCE.fixer.update(References.BLOCK_STATE, dynamic, srcVer, DATA_VERSION).getValue();
- return nbtToState(fixed);
- }
-
- private String nbtToState(CompoundTag tagCompound) {
- StringBuilder sb = new StringBuilder();
- sb.append(tagCompound.getString("Name"));
- if (tagCompound.contains("Properties", 10)) {
- sb.append('[');
- CompoundTag props = tagCompound.getCompound("Properties");
- sb.append(props.getAllKeys().stream().map(k -> k + "=" + props.getString(k).replace("\"", "")).collect(Collectors.joining(",")));
- sb.append(']');
- }
- return sb.toString();
- }
-
- private static CompoundTag stateToNBT(String blockState) {
- int propIdx = blockState.indexOf('[');
- CompoundTag tag = new CompoundTag();
- if (propIdx < 0) {
- tag.putString("Name", blockState);
- } else {
- tag.putString("Name", blockState.substring(0, propIdx));
- CompoundTag propTag = new CompoundTag();
- String props = blockState.substring(propIdx + 1, blockState.length() - 1);
- String[] propArr = props.split(",");
- for (String pair : propArr) {
- final String[] split = pair.split("=");
- propTag.putString(split[0], split[1]);
- }
- tag.put("Properties", propTag);
- }
- return tag;
- }
-
- private String fixBiome(String key, int srcVer) {
- return fixName(key, srcVer, References.BIOME);
- }
-
- private String fixItemType(String key, int srcVer) {
- return fixName(key, srcVer, References.ITEM_NAME);
- }
-
- private static String fixName(String key, int srcVer, TypeReference type) {
- return INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, StringTag.valueOf(key)), srcVer, DATA_VERSION)
- .getValue().getAsString();
- }
-
- private final PaperweightAdapter adapter;
-
- private static final NbtOps OPS_NBT = NbtOps.INSTANCE;
- private static final int LEGACY_VERSION = 1343;
- private static int DATA_VERSION;
- static PaperweightDataConverters INSTANCE;
-
- private final Map> converters = new EnumMap<>(LegacyType.class);
- private final Map> inspectors = new EnumMap<>(LegacyType.class);
-
- // Set on build
- private DataFixer fixer;
- private static final Map DFU_TO_LEGACY = new HashMap<>();
-
- public enum LegacyType {
- LEVEL(References.LEVEL),
- PLAYER(References.PLAYER),
- CHUNK(References.CHUNK),
- BLOCK_ENTITY(References.BLOCK_ENTITY),
- ENTITY(References.ENTITY),
- ITEM_INSTANCE(References.ITEM_STACK),
- OPTIONS(References.OPTIONS),
- STRUCTURE(References.STRUCTURE);
-
- private final TypeReference type;
-
- LegacyType(TypeReference type) {
- this.type = type;
- DFU_TO_LEGACY.put(type.typeName(), this);
- }
-
- public TypeReference getDFUType() {
- return type;
- }
- }
-
- PaperweightDataConverters(int dataVersion, PaperweightAdapter adapter) {
- super(dataVersion);
- DATA_VERSION = dataVersion;
- INSTANCE = this;
- this.adapter = adapter;
- registerConverters();
- registerInspectors();
- }
-
-
- // Called after fixers are built and ready for FIXING
- @Override
- public DataFixer build(final Executor executor) {
- return this.fixer = new WrappedDataFixer(DataFixers.getDataFixer());
- }
-
- @SuppressWarnings("unchecked")
- private class WrappedDataFixer implements DataFixer {
- private final DataFixer realFixer;
-
- WrappedDataFixer(DataFixer realFixer) {
- this.realFixer = realFixer;
- }
-
- @Override
- public Dynamic update(TypeReference type, Dynamic dynamic, int sourceVer, int targetVer) {
- LegacyType legacyType = DFU_TO_LEGACY.get(type.typeName());
- if (sourceVer < LEGACY_VERSION && legacyType != null) {
- CompoundTag cmp = (CompoundTag) dynamic.getValue();
- int desiredVersion = Math.min(targetVer, LEGACY_VERSION);
-
- cmp = convert(legacyType, cmp, sourceVer, desiredVersion);
- sourceVer = desiredVersion;
- dynamic = new Dynamic(OPS_NBT, cmp);
- }
- return realFixer.update(type, dynamic, sourceVer, targetVer);
- }
-
- private CompoundTag convert(LegacyType type, CompoundTag cmp, int sourceVer, int desiredVersion) {
- List converters = PaperweightDataConverters.this.converters.get(type);
- if (converters != null && !converters.isEmpty()) {
- for (DataConverter converter : converters) {
- int dataVersion = converter.getDataVersion();
- if (dataVersion > sourceVer && dataVersion <= desiredVersion) {
- cmp = converter.convert(cmp);
- }
- }
- }
-
- List inspectors = PaperweightDataConverters.this.inspectors.get(type);
- if (inspectors != null && !inspectors.isEmpty()) {
- for (DataInspector inspector : inspectors) {
- cmp = inspector.inspect(cmp, sourceVer, desiredVersion);
- }
- }
-
- return cmp;
- }
-
- @Override
- public Schema getSchema(int i) {
- return realFixer.getSchema(i);
- }
- }
-
- public static CompoundTag convert(LegacyType type, CompoundTag cmp) {
- return convert(type.getDFUType(), cmp);
- }
-
- public static CompoundTag convert(LegacyType type, CompoundTag cmp, int sourceVer) {
- return convert(type.getDFUType(), cmp, sourceVer);
- }
-
- public static CompoundTag convert(LegacyType type, CompoundTag cmp, int sourceVer, int targetVer) {
- return convert(type.getDFUType(), cmp, sourceVer, targetVer);
- }
-
- public static CompoundTag convert(TypeReference type, CompoundTag cmp) {
- int i = cmp.contains("DataVersion", 99) ? cmp.getInt("DataVersion") : -1;
- return convert(type, cmp, i);
- }
-
- public static CompoundTag convert(TypeReference type, CompoundTag cmp, int sourceVer) {
- return convert(type, cmp, sourceVer, DATA_VERSION);
- }
-
- public static CompoundTag convert(TypeReference type, CompoundTag cmp, int sourceVer, int targetVer) {
- if (sourceVer >= targetVer) {
- return cmp;
- }
- return (CompoundTag) INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, cmp), sourceVer, targetVer).getValue();
- }
-
-
- public interface DataInspector {
- CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer);
- }
-
- public interface DataConverter {
-
- int getDataVersion();
-
- CompoundTag convert(CompoundTag cmp);
- }
-
-
- private void registerInspector(LegacyType type, DataInspector inspector) {
- this.inspectors.computeIfAbsent(type, k -> new ArrayList<>()).add(inspector);
- }
-
- private void registerConverter(LegacyType type, DataConverter converter) {
- int version = converter.getDataVersion();
-
- List list = this.converters.computeIfAbsent(type, k -> new ArrayList<>());
- if (!list.isEmpty() && list.get(list.size() - 1).getDataVersion() > version) {
- for (int j = 0; j < list.size(); ++j) {
- if (list.get(j).getDataVersion() > version) {
- list.add(j, converter);
- break;
- }
- }
- } else {
- list.add(converter);
- }
- }
-
- private void registerInspectors() {
- registerEntityItemList("EntityHorseDonkey", "SaddleItem", "Items");
- registerEntityItemList("EntityHorseMule", "Items");
- registerEntityItemList("EntityMinecartChest", "Items");
- registerEntityItemList("EntityMinecartHopper", "Items");
- registerEntityItemList("EntityVillager", "Inventory");
- registerEntityItemListEquipment("EntityArmorStand");
- registerEntityItemListEquipment("EntityBat");
- registerEntityItemListEquipment("EntityBlaze");
- registerEntityItemListEquipment("EntityCaveSpider");
- registerEntityItemListEquipment("EntityChicken");
- registerEntityItemListEquipment("EntityCow");
- registerEntityItemListEquipment("EntityCreeper");
- registerEntityItemListEquipment("EntityEnderDragon");
- registerEntityItemListEquipment("EntityEnderman");
- registerEntityItemListEquipment("EntityEndermite");
- registerEntityItemListEquipment("EntityEvoker");
- registerEntityItemListEquipment("EntityGhast");
- registerEntityItemListEquipment("EntityGiantZombie");
- registerEntityItemListEquipment("EntityGuardian");
- registerEntityItemListEquipment("EntityGuardianElder");
- registerEntityItemListEquipment("EntityHorse");
- registerEntityItemListEquipment("EntityHorseDonkey");
- registerEntityItemListEquipment("EntityHorseMule");
- registerEntityItemListEquipment("EntityHorseSkeleton");
- registerEntityItemListEquipment("EntityHorseZombie");
- registerEntityItemListEquipment("EntityIronGolem");
- registerEntityItemListEquipment("EntityMagmaCube");
- registerEntityItemListEquipment("EntityMushroomCow");
- registerEntityItemListEquipment("EntityOcelot");
- registerEntityItemListEquipment("EntityPig");
- registerEntityItemListEquipment("EntityPigZombie");
- registerEntityItemListEquipment("EntityRabbit");
- registerEntityItemListEquipment("EntitySheep");
- registerEntityItemListEquipment("EntityShulker");
- registerEntityItemListEquipment("EntitySilverfish");
- registerEntityItemListEquipment("EntitySkeleton");
- registerEntityItemListEquipment("EntitySkeletonStray");
- registerEntityItemListEquipment("EntitySkeletonWither");
- registerEntityItemListEquipment("EntitySlime");
- registerEntityItemListEquipment("EntitySnowman");
- registerEntityItemListEquipment("EntitySpider");
- registerEntityItemListEquipment("EntitySquid");
- registerEntityItemListEquipment("EntityVex");
- registerEntityItemListEquipment("EntityVillager");
- registerEntityItemListEquipment("EntityVindicator");
- registerEntityItemListEquipment("EntityWitch");
- registerEntityItemListEquipment("EntityWither");
- registerEntityItemListEquipment("EntityWolf");
- registerEntityItemListEquipment("EntityZombie");
- registerEntityItemListEquipment("EntityZombieHusk");
- registerEntityItemListEquipment("EntityZombieVillager");
- registerEntityItemSingle("EntityFireworks", "FireworksItem");
- registerEntityItemSingle("EntityHorse", "ArmorItem");
- registerEntityItemSingle("EntityHorse", "SaddleItem");
- registerEntityItemSingle("EntityHorseMule", "SaddleItem");
- registerEntityItemSingle("EntityHorseSkeleton", "SaddleItem");
- registerEntityItemSingle("EntityHorseZombie", "SaddleItem");
- registerEntityItemSingle("EntityItem", "Item");
- registerEntityItemSingle("EntityItemFrame", "Item");
- registerEntityItemSingle("EntityPotion", "Potion");
-
- registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItem("TileEntityRecordPlayer", "RecordItem"));
- registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityBrewingStand", "Items"));
- registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityChest", "Items"));
- registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityDispenser", "Items"));
- registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityDropper", "Items"));
- registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityFurnace", "Items"));
- registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityHopper", "Items"));
- registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityShulkerBox", "Items"));
- registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorMobSpawnerMobs());
- registerInspector(LegacyType.CHUNK, new DataInspectorChunks());
- registerInspector(LegacyType.ENTITY, new DataInspectorCommandBlock());
- registerInspector(LegacyType.ENTITY, new DataInspectorEntityPassengers());
- registerInspector(LegacyType.ENTITY, new DataInspectorMobSpawnerMinecart());
- registerInspector(LegacyType.ENTITY, new DataInspectorVillagers());
- registerInspector(LegacyType.ITEM_INSTANCE, new DataInspectorBlockEntity());
- registerInspector(LegacyType.ITEM_INSTANCE, new DataInspectorEntity());
- registerInspector(LegacyType.LEVEL, new DataInspectorLevelPlayer());
- registerInspector(LegacyType.PLAYER, new DataInspectorPlayer());
- registerInspector(LegacyType.PLAYER, new DataInspectorPlayerVehicle());
- registerInspector(LegacyType.STRUCTURE, new DataInspectorStructure());
- }
-
- private void registerConverters() {
- registerConverter(LegacyType.ENTITY, new DataConverterEquipment());
- registerConverter(LegacyType.BLOCK_ENTITY, new DataConverterSignText());
- registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterMaterialId());
- registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterPotionId());
- registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterSpawnEgg());
- registerConverter(LegacyType.ENTITY, new DataConverterMinecart());
- registerConverter(LegacyType.BLOCK_ENTITY, new DataConverterMobSpawner());
- registerConverter(LegacyType.ENTITY, new DataConverterUUID());
- registerConverter(LegacyType.ENTITY, new DataConverterHealth());
- registerConverter(LegacyType.ENTITY, new DataConverterSaddle());
- registerConverter(LegacyType.ENTITY, new DataConverterHanging());
- registerConverter(LegacyType.ENTITY, new DataConverterDropChances());
- registerConverter(LegacyType.ENTITY, new DataConverterRiding());
- registerConverter(LegacyType.ENTITY, new DataConverterArmorStand());
- registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterBook());
- registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterCookedFish());
- registerConverter(LegacyType.ENTITY, new DataConverterZombie());
- registerConverter(LegacyType.OPTIONS, new DataConverterVBO());
- registerConverter(LegacyType.ENTITY, new DataConverterGuardian());
- registerConverter(LegacyType.ENTITY, new DataConverterSkeleton());
- registerConverter(LegacyType.ENTITY, new DataConverterZombieType());
- registerConverter(LegacyType.ENTITY, new DataConverterHorse());
- registerConverter(LegacyType.BLOCK_ENTITY, new DataConverterTileEntity());
- registerConverter(LegacyType.ENTITY, new DataConverterEntity());
- registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterBanner());
- registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterPotionWater());
- registerConverter(LegacyType.ENTITY, new DataConverterShulker());
- registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterShulkerBoxItem());
- registerConverter(LegacyType.BLOCK_ENTITY, new DataConverterShulkerBoxBlock());
- registerConverter(LegacyType.OPTIONS, new DataConverterLang());
- registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterTotem());
- registerConverter(LegacyType.CHUNK, new DataConverterBedBlock());
- registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterBedItem());
- }
-
- private void registerEntityItemList(String type, String... keys) {
- registerInspector(LegacyType.ENTITY, new DataInspectorItemList(type, keys));
- }
-
- private void registerEntityItemSingle(String type, String key) {
- registerInspector(LegacyType.ENTITY, new DataInspectorItem(type, key));
- }
-
- private void registerEntityItemListEquipment(String type) {
- registerEntityItemList(type, "ArmorItems", "HandItems");
- }
-
- private static final Map OLD_ID_TO_KEY_MAP = new HashMap<>();
-
- static {
- final Map map = OLD_ID_TO_KEY_MAP;
- map.put("EntityItem", new ResourceLocation("item"));
- map.put("EntityExperienceOrb", new ResourceLocation("xp_orb"));
- map.put("EntityAreaEffectCloud", new ResourceLocation("area_effect_cloud"));
- map.put("EntityGuardianElder", new ResourceLocation("elder_guardian"));
- map.put("EntitySkeletonWither", new ResourceLocation("wither_skeleton"));
- map.put("EntitySkeletonStray", new ResourceLocation("stray"));
- map.put("EntityEgg", new ResourceLocation("egg"));
- map.put("EntityLeash", new ResourceLocation("leash_knot"));
- map.put("EntityPainting", new ResourceLocation("painting"));
- map.put("EntityTippedArrow", new ResourceLocation("arrow"));
- map.put("EntitySnowball", new ResourceLocation("snowball"));
- map.put("EntityLargeFireball", new ResourceLocation("fireball"));
- map.put("EntitySmallFireball", new ResourceLocation("small_fireball"));
- map.put("EntityEnderPearl", new ResourceLocation("ender_pearl"));
- map.put("EntityEnderSignal", new ResourceLocation("eye_of_ender_signal"));
- map.put("EntityPotion", new ResourceLocation("potion"));
- map.put("EntityThrownExpBottle", new ResourceLocation("xp_bottle"));
- map.put("EntityItemFrame", new ResourceLocation("item_frame"));
- map.put("EntityWitherSkull", new ResourceLocation("wither_skull"));
- map.put("EntityTNTPrimed", new ResourceLocation("tnt"));
- map.put("EntityFallingBlock", new ResourceLocation("falling_block"));
- map.put("EntityFireworks", new ResourceLocation("fireworks_rocket"));
- map.put("EntityZombieHusk", new ResourceLocation("husk"));
- map.put("EntitySpectralArrow", new ResourceLocation("spectral_arrow"));
- map.put("EntityShulkerBullet", new ResourceLocation("shulker_bullet"));
- map.put("EntityDragonFireball", new ResourceLocation("dragon_fireball"));
- map.put("EntityZombieVillager", new ResourceLocation("zombie_villager"));
- map.put("EntityHorseSkeleton", new ResourceLocation("skeleton_horse"));
- map.put("EntityHorseZombie", new ResourceLocation("zombie_horse"));
- map.put("EntityArmorStand", new ResourceLocation("armor_stand"));
- map.put("EntityHorseDonkey", new ResourceLocation("donkey"));
- map.put("EntityHorseMule", new ResourceLocation("mule"));
- map.put("EntityEvokerFangs", new ResourceLocation("evocation_fangs"));
- map.put("EntityEvoker", new ResourceLocation("evocation_illager"));
- map.put("EntityVex", new ResourceLocation("vex"));
- map.put("EntityVindicator", new ResourceLocation("vindication_illager"));
- map.put("EntityIllagerIllusioner", new ResourceLocation("illusion_illager"));
- map.put("EntityMinecartCommandBlock", new ResourceLocation("commandblock_minecart"));
- map.put("EntityBoat", new ResourceLocation("boat"));
- map.put("EntityMinecartRideable", new ResourceLocation("minecart"));
- map.put("EntityMinecartChest", new ResourceLocation("chest_minecart"));
- map.put("EntityMinecartFurnace", new ResourceLocation("furnace_minecart"));
- map.put("EntityMinecartTNT", new ResourceLocation("tnt_minecart"));
- map.put("EntityMinecartHopper", new ResourceLocation("hopper_minecart"));
- map.put("EntityMinecartMobSpawner", new ResourceLocation("spawner_minecart"));
- map.put("EntityCreeper", new ResourceLocation("creeper"));
- map.put("EntitySkeleton", new ResourceLocation("skeleton"));
- map.put("EntitySpider", new ResourceLocation("spider"));
- map.put("EntityGiantZombie", new ResourceLocation("giant"));
- map.put("EntityZombie", new ResourceLocation("zombie"));
- map.put("EntitySlime", new ResourceLocation("slime"));
- map.put("EntityGhast", new ResourceLocation("ghast"));
- map.put("EntityPigZombie", new ResourceLocation("zombie_pigman"));
- map.put("EntityEnderman", new ResourceLocation("enderman"));
- map.put("EntityCaveSpider", new ResourceLocation("cave_spider"));
- map.put("EntitySilverfish", new ResourceLocation("silverfish"));
- map.put("EntityBlaze", new ResourceLocation("blaze"));
- map.put("EntityMagmaCube", new ResourceLocation("magma_cube"));
- map.put("EntityEnderDragon", new ResourceLocation("ender_dragon"));
- map.put("EntityWither", new ResourceLocation("wither"));
- map.put("EntityBat", new ResourceLocation("bat"));
- map.put("EntityWitch", new ResourceLocation("witch"));
- map.put("EntityEndermite", new ResourceLocation("endermite"));
- map.put("EntityGuardian", new ResourceLocation("guardian"));
- map.put("EntityShulker", new ResourceLocation("shulker"));
- map.put("EntityPig", new ResourceLocation("pig"));
- map.put("EntitySheep", new ResourceLocation("sheep"));
- map.put("EntityCow", new ResourceLocation("cow"));
- map.put("EntityChicken", new ResourceLocation("chicken"));
- map.put("EntitySquid", new ResourceLocation("squid"));
- map.put("EntityWolf", new ResourceLocation("wolf"));
- map.put("EntityMushroomCow", new ResourceLocation("mooshroom"));
- map.put("EntitySnowman", new ResourceLocation("snowman"));
- map.put("EntityOcelot", new ResourceLocation("ocelot"));
- map.put("EntityIronGolem", new ResourceLocation("villager_golem"));
- map.put("EntityHorse", new ResourceLocation("horse"));
- map.put("EntityRabbit", new ResourceLocation("rabbit"));
- map.put("EntityPolarBear", new ResourceLocation("polar_bear"));
- map.put("EntityLlama", new ResourceLocation("llama"));
- map.put("EntityLlamaSpit", new ResourceLocation("llama_spit"));
- map.put("EntityParrot", new ResourceLocation("parrot"));
- map.put("EntityVillager", new ResourceLocation("villager"));
- map.put("EntityEnderCrystal", new ResourceLocation("ender_crystal"));
- map.put("TileEntityFurnace", new ResourceLocation("furnace"));
- map.put("TileEntityChest", new ResourceLocation("chest"));
- map.put("TileEntityEnderChest", new ResourceLocation("ender_chest"));
- map.put("TileEntityRecordPlayer", new ResourceLocation("jukebox"));
- map.put("TileEntityDispenser", new ResourceLocation("dispenser"));
- map.put("TileEntityDropper", new ResourceLocation("dropper"));
- map.put("TileEntitySign", new ResourceLocation("sign"));
- map.put("TileEntityMobSpawner", new ResourceLocation("mob_spawner"));
- map.put("TileEntityNote", new ResourceLocation("noteblock"));
- map.put("TileEntityPiston", new ResourceLocation("piston"));
- map.put("TileEntityBrewingStand", new ResourceLocation("brewing_stand"));
- map.put("TileEntityEnchantTable", new ResourceLocation("enchanting_table"));
- map.put("TileEntityEnderPortal", new ResourceLocation("end_portal"));
- map.put("TileEntityBeacon", new ResourceLocation("beacon"));
- map.put("TileEntitySkull", new ResourceLocation("skull"));
- map.put("TileEntityLightDetector", new ResourceLocation("daylight_detector"));
- map.put("TileEntityHopper", new ResourceLocation("hopper"));
- map.put("TileEntityComparator", new ResourceLocation("comparator"));
- map.put("TileEntityFlowerPot", new ResourceLocation("flower_pot"));
- map.put("TileEntityBanner", new ResourceLocation("banner"));
- map.put("TileEntityStructure", new ResourceLocation("structure_block"));
- map.put("TileEntityEndGateway", new ResourceLocation("end_gateway"));
- map.put("TileEntityCommand", new ResourceLocation("command_block"));
- map.put("TileEntityShulkerBox", new ResourceLocation("shulker_box"));
- map.put("TileEntityBed", new ResourceLocation("bed"));
- }
-
- private static ResourceLocation getKey(String type) {
- final ResourceLocation key = OLD_ID_TO_KEY_MAP.get(type);
- if (key == null) {
- throw new IllegalArgumentException("Unknown mapping for " + type);
- }
- return key;
- }
-
- private static void convertCompound(LegacyType type, CompoundTag cmp, String key, int sourceVer, int targetVer) {
- cmp.put(key, convert(type, cmp.getCompound(key), sourceVer, targetVer));
- }
-
- private static void convertItem(CompoundTag nbttagcompound, String key, int sourceVer, int targetVer) {
- if (nbttagcompound.contains(key, 10)) {
- convertCompound(LegacyType.ITEM_INSTANCE, nbttagcompound, key, sourceVer, targetVer);
- }
- }
-
- private static void convertItems(CompoundTag nbttagcompound, String key, int sourceVer, int targetVer) {
- if (nbttagcompound.contains(key, 9)) {
- ListTag nbttaglist = nbttagcompound.getList(key, 10);
-
- for (int j = 0; j < nbttaglist.size(); ++j) {
- nbttaglist.set(j, convert(LegacyType.ITEM_INSTANCE, nbttaglist.getCompound(j), sourceVer, targetVer));
- }
- }
-
- }
-
- private static class DataConverterEquipment implements DataConverter {
-
- DataConverterEquipment() {
- }
-
- public int getDataVersion() {
- return 100;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- ListTag nbttaglist = cmp.getList("Equipment", 10);
- ListTag nbttaglist1;
-
- if (!nbttaglist.isEmpty() && !cmp.contains("HandItems", 10)) {
- nbttaglist1 = new ListTag();
- nbttaglist1.add(nbttaglist.get(0));
- nbttaglist1.add(new CompoundTag());
- cmp.put("HandItems", nbttaglist1);
- }
-
- if (nbttaglist.size() > 1 && !cmp.contains("ArmorItem", 10)) {
- nbttaglist1 = new ListTag();
- nbttaglist1.add(nbttaglist.get(1));
- nbttaglist1.add(nbttaglist.get(2));
- nbttaglist1.add(nbttaglist.get(3));
- nbttaglist1.add(nbttaglist.get(4));
- cmp.put("ArmorItems", nbttaglist1);
- }
-
- cmp.remove("Equipment");
- if (cmp.contains("DropChances", 9)) {
- nbttaglist1 = cmp.getList("DropChances", 5);
- ListTag nbttaglist2;
-
- if (!cmp.contains("HandDropChances", 10)) {
- nbttaglist2 = new ListTag();
- nbttaglist2.add(FloatTag.valueOf(nbttaglist1.getFloat(0)));
- nbttaglist2.add(FloatTag.valueOf(0.0F));
- cmp.put("HandDropChances", nbttaglist2);
- }
-
- if (!cmp.contains("ArmorDropChances", 10)) {
- nbttaglist2 = new ListTag();
- nbttaglist2.add(FloatTag.valueOf(nbttaglist1.getFloat(1)));
- nbttaglist2.add(FloatTag.valueOf(nbttaglist1.getFloat(2)));
- nbttaglist2.add(FloatTag.valueOf(nbttaglist1.getFloat(3)));
- nbttaglist2.add(FloatTag.valueOf(nbttaglist1.getFloat(4)));
- cmp.put("ArmorDropChances", nbttaglist2);
- }
-
- cmp.remove("DropChances");
- }
-
- return cmp;
- }
- }
-
- private static class DataInspectorBlockEntity implements DataInspector {
-
- private static final Map b = Maps.newHashMap();
- private static final Map c = Maps.newHashMap();
-
- DataInspectorBlockEntity() {
- }
-
- @Nullable
- private static String convertEntityId(int i, String s) {
- String key = new ResourceLocation(s).toString();
- if (i < 515 && DataInspectorBlockEntity.b.containsKey(key)) {
- return DataInspectorBlockEntity.b.get(key);
- } else {
- return DataInspectorBlockEntity.c.get(key);
- }
- }
-
- public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
- if (!cmp.contains("tag", 10)) {
- return cmp;
- } else {
- CompoundTag nbttagcompound1 = cmp.getCompound("tag");
-
- if (nbttagcompound1.contains("BlockEntityTag", 10)) {
- CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
- String s = cmp.getString("id");
- String s1 = convertEntityId(sourceVer, s);
- boolean flag;
-
- if (s1 == null) {
- // CraftBukkit - Remove unnecessary warning (occurs when deserializing a Shulker Box item)
- // DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", s);
- flag = false;
- } else {
- flag = !nbttagcompound2.contains("id");
- nbttagcompound2.putString("id", s1);
- }
-
- convert(LegacyType.BLOCK_ENTITY, nbttagcompound2, sourceVer, targetVer);
- if (flag) {
- nbttagcompound2.remove("id");
- }
- }
-
- return cmp;
- }
- }
-
- static {
- Map map = DataInspectorBlockEntity.b;
-
- map.put("minecraft:furnace", "Furnace");
- map.put("minecraft:lit_furnace", "Furnace");
- map.put("minecraft:chest", "Chest");
- map.put("minecraft:trapped_chest", "Chest");
- map.put("minecraft:ender_chest", "EnderChest");
- map.put("minecraft:jukebox", "RecordPlayer");
- map.put("minecraft:dispenser", "Trap");
- map.put("minecraft:dropper", "Dropper");
- map.put("minecraft:sign", "Sign");
- map.put("minecraft:mob_spawner", "MobSpawner");
- map.put("minecraft:noteblock", "Music");
- map.put("minecraft:brewing_stand", "Cauldron");
- map.put("minecraft:enhanting_table", "EnchantTable");
- map.put("minecraft:command_block", "CommandBlock");
- map.put("minecraft:beacon", "Beacon");
- map.put("minecraft:skull", "Skull");
- map.put("minecraft:daylight_detector", "DLDetector");
- map.put("minecraft:hopper", "Hopper");
- map.put("minecraft:banner", "Banner");
- map.put("minecraft:flower_pot", "FlowerPot");
- map.put("minecraft:repeating_command_block", "CommandBlock");
- map.put("minecraft:chain_command_block", "CommandBlock");
- map.put("minecraft:standing_sign", "Sign");
- map.put("minecraft:wall_sign", "Sign");
- map.put("minecraft:piston_head", "Piston");
- map.put("minecraft:daylight_detector_inverted", "DLDetector");
- map.put("minecraft:unpowered_comparator", "Comparator");
- map.put("minecraft:powered_comparator", "Comparator");
- map.put("minecraft:wall_banner", "Banner");
- map.put("minecraft:standing_banner", "Banner");
- map.put("minecraft:structure_block", "Structure");
- map.put("minecraft:end_portal", "Airportal");
- map.put("minecraft:end_gateway", "EndGateway");
- map.put("minecraft:shield", "Shield");
- map = DataInspectorBlockEntity.c;
- map.put("minecraft:furnace", "minecraft:furnace");
- map.put("minecraft:lit_furnace", "minecraft:furnace");
- map.put("minecraft:chest", "minecraft:chest");
- map.put("minecraft:trapped_chest", "minecraft:chest");
- map.put("minecraft:ender_chest", "minecraft:enderchest");
- map.put("minecraft:jukebox", "minecraft:jukebox");
- map.put("minecraft:dispenser", "minecraft:dispenser");
- map.put("minecraft:dropper", "minecraft:dropper");
- map.put("minecraft:sign", "minecraft:sign");
- map.put("minecraft:mob_spawner", "minecraft:mob_spawner");
- map.put("minecraft:noteblock", "minecraft:noteblock");
- map.put("minecraft:brewing_stand", "minecraft:brewing_stand");
- map.put("minecraft:enhanting_table", "minecraft:enchanting_table");
- map.put("minecraft:command_block", "minecraft:command_block");
- map.put("minecraft:beacon", "minecraft:beacon");
- map.put("minecraft:skull", "minecraft:skull");
- map.put("minecraft:daylight_detector", "minecraft:daylight_detector");
- map.put("minecraft:hopper", "minecraft:hopper");
- map.put("minecraft:banner", "minecraft:banner");
- map.put("minecraft:flower_pot", "minecraft:flower_pot");
- map.put("minecraft:repeating_command_block", "minecraft:command_block");
- map.put("minecraft:chain_command_block", "minecraft:command_block");
- map.put("minecraft:shulker_box", "minecraft:shulker_box");
- map.put("minecraft:white_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:orange_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:magenta_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:light_blue_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:yellow_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:lime_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:pink_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:gray_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:silver_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:cyan_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:purple_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:blue_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:brown_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:green_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:red_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:black_shulker_box", "minecraft:shulker_box");
- map.put("minecraft:bed", "minecraft:bed");
- map.put("minecraft:standing_sign", "minecraft:sign");
- map.put("minecraft:wall_sign", "minecraft:sign");
- map.put("minecraft:piston_head", "minecraft:piston");
- map.put("minecraft:daylight_detector_inverted", "minecraft:daylight_detector");
- map.put("minecraft:unpowered_comparator", "minecraft:comparator");
- map.put("minecraft:powered_comparator", "minecraft:comparator");
- map.put("minecraft:wall_banner", "minecraft:banner");
- map.put("minecraft:standing_banner", "minecraft:banner");
- map.put("minecraft:structure_block", "minecraft:structure_block");
- map.put("minecraft:end_portal", "minecraft:end_portal");
- map.put("minecraft:end_gateway", "minecraft:end_gateway");
- map.put("minecraft:shield", "minecraft:shield");
- }
- }
-
- private static class DataInspectorEntity implements DataInspector {
-
- private static final Logger a = LogManager.getLogger(PaperweightDataConverters.class);
-
- DataInspectorEntity() {
- }
-
- public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
- CompoundTag nbttagcompound1 = cmp.getCompound("tag");
-
- if (nbttagcompound1.contains("EntityTag", 10)) {
- CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("EntityTag");
- String s = cmp.getString("id");
- String s1;
-
- if ("minecraft:armor_stand".equals(s)) {
- s1 = sourceVer < 515 ? "ArmorStand" : "minecraft:armor_stand";
- } else {
- if (!"minecraft:spawn_egg".equals(s)) {
- return cmp;
- }
-
- s1 = nbttagcompound2.getString("id");
- }
-
- boolean flag;
-
- flag = !nbttagcompound2.contains("id", 8);
- nbttagcompound2.putString("id", s1);
-
- convert(LegacyType.ENTITY, nbttagcompound2, sourceVer, targetVer);
- if (flag) {
- nbttagcompound2.remove("id");
- }
- }
-
- return cmp;
- }
- }
-
-
- private abstract static class DataInspectorTagged implements DataInspector {
-
- private final ResourceLocation key;
-
- DataInspectorTagged(String type) {
- this.key = getKey(type);
- }
-
- public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
- if (this.key.equals(new ResourceLocation(cmp.getString("id")))) {
- cmp = this.inspectChecked(cmp, sourceVer, targetVer);
- }
-
- return cmp;
- }
-
- abstract CompoundTag inspectChecked(CompoundTag nbttagcompound, int sourceVer, int targetVer);
- }
-
- private static class DataInspectorItemList extends DataInspectorTagged {
-
- private final String[] keys;
-
- DataInspectorItemList(String oclass, String... astring) {
- super(oclass);
- this.keys = astring;
- }
-
- CompoundTag inspectChecked(CompoundTag nbttagcompound, int sourceVer, int targetVer) {
- for (String s : this.keys) {
- PaperweightDataConverters.convertItems(nbttagcompound, s, sourceVer, targetVer);
- }
-
- return nbttagcompound;
- }
- }
-
- private static class DataInspectorItem extends DataInspectorTagged {
-
- private final String[] keys;
-
- DataInspectorItem(String oclass, String... astring) {
- super(oclass);
- this.keys = astring;
- }
-
- CompoundTag inspectChecked(CompoundTag nbttagcompound, int sourceVer, int targetVer) {
- for (String key : this.keys) {
- PaperweightDataConverters.convertItem(nbttagcompound, key, sourceVer, targetVer);
- }
-
- return nbttagcompound;
- }
- }
-
- private static class DataConverterMaterialId implements DataConverter {
-
- private static final String[] materials = new String[2268];
-
- DataConverterMaterialId() {
- }
-
- public int getDataVersion() {
- return 102;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if (cmp.contains("id", 99)) {
- short short0 = cmp.getShort("id");
-
- if (short0 > 0 && short0 < materials.length && materials[short0] != null) {
- cmp.putString("id", materials[short0]);
- }
- }
-
- return cmp;
- }
-
- static {
- materials[1] = "minecraft:stone";
- materials[2] = "minecraft:grass";
- materials[3] = "minecraft:dirt";
- materials[4] = "minecraft:cobblestone";
- materials[5] = "minecraft:planks";
- materials[6] = "minecraft:sapling";
- materials[7] = "minecraft:bedrock";
- materials[8] = "minecraft:flowing_water";
- materials[9] = "minecraft:water";
- materials[10] = "minecraft:flowing_lava";
- materials[11] = "minecraft:lava";
- materials[12] = "minecraft:sand";
- materials[13] = "minecraft:gravel";
- materials[14] = "minecraft:gold_ore";
- materials[15] = "minecraft:iron_ore";
- materials[16] = "minecraft:coal_ore";
- materials[17] = "minecraft:log";
- materials[18] = "minecraft:leaves";
- materials[19] = "minecraft:sponge";
- materials[20] = "minecraft:glass";
- materials[21] = "minecraft:lapis_ore";
- materials[22] = "minecraft:lapis_block";
- materials[23] = "minecraft:dispenser";
- materials[24] = "minecraft:sandstone";
- materials[25] = "minecraft:noteblock";
- materials[27] = "minecraft:golden_rail";
- materials[28] = "minecraft:detector_rail";
- materials[29] = "minecraft:sticky_piston";
- materials[30] = "minecraft:web";
- materials[31] = "minecraft:tallgrass";
- materials[32] = "minecraft:deadbush";
- materials[33] = "minecraft:piston";
- materials[35] = "minecraft:wool";
- materials[37] = "minecraft:yellow_flower";
- materials[38] = "minecraft:red_flower";
- materials[39] = "minecraft:brown_mushroom";
- materials[40] = "minecraft:red_mushroom";
- materials[41] = "minecraft:gold_block";
- materials[42] = "minecraft:iron_block";
- materials[43] = "minecraft:double_stone_slab";
- materials[44] = "minecraft:stone_slab";
- materials[45] = "minecraft:brick_block";
- materials[46] = "minecraft:tnt";
- materials[47] = "minecraft:bookshelf";
- materials[48] = "minecraft:mossy_cobblestone";
- materials[49] = "minecraft:obsidian";
- materials[50] = "minecraft:torch";
- materials[51] = "minecraft:fire";
- materials[52] = "minecraft:mob_spawner";
- materials[53] = "minecraft:oak_stairs";
- materials[54] = "minecraft:chest";
- materials[56] = "minecraft:diamond_ore";
- materials[57] = "minecraft:diamond_block";
- materials[58] = "minecraft:crafting_table";
- materials[60] = "minecraft:farmland";
- materials[61] = "minecraft:furnace";
- materials[62] = "minecraft:lit_furnace";
- materials[65] = "minecraft:ladder";
- materials[66] = "minecraft:rail";
- materials[67] = "minecraft:stone_stairs";
- materials[69] = "minecraft:lever";
- materials[70] = "minecraft:stone_pressure_plate";
- materials[72] = "minecraft:wooden_pressure_plate";
- materials[73] = "minecraft:redstone_ore";
- materials[76] = "minecraft:redstone_torch";
- materials[77] = "minecraft:stone_button";
- materials[78] = "minecraft:snow_layer";
- materials[79] = "minecraft:ice";
- materials[80] = "minecraft:snow";
- materials[81] = "minecraft:cactus";
- materials[82] = "minecraft:clay";
- materials[84] = "minecraft:jukebox";
- materials[85] = "minecraft:fence";
- materials[86] = "minecraft:pumpkin";
- materials[87] = "minecraft:netherrack";
- materials[88] = "minecraft:soul_sand";
- materials[89] = "minecraft:glowstone";
- materials[90] = "minecraft:portal";
- materials[91] = "minecraft:lit_pumpkin";
- materials[95] = "minecraft:stained_glass";
- materials[96] = "minecraft:trapdoor";
- materials[97] = "minecraft:monster_egg";
- materials[98] = "minecraft:stonebrick";
- materials[99] = "minecraft:brown_mushroom_block";
- materials[100] = "minecraft:red_mushroom_block";
- materials[101] = "minecraft:iron_bars";
- materials[102] = "minecraft:glass_pane";
- materials[103] = "minecraft:melon_block";
- materials[106] = "minecraft:vine";
- materials[107] = "minecraft:fence_gate";
- materials[108] = "minecraft:brick_stairs";
- materials[109] = "minecraft:stone_brick_stairs";
- materials[110] = "minecraft:mycelium";
- materials[111] = "minecraft:waterlily";
- materials[112] = "minecraft:nether_brick";
- materials[113] = "minecraft:nether_brick_fence";
- materials[114] = "minecraft:nether_brick_stairs";
- materials[116] = "minecraft:enchanting_table";
- materials[119] = "minecraft:end_portal";
- materials[120] = "minecraft:end_portal_frame";
- materials[121] = "minecraft:end_stone";
- materials[122] = "minecraft:dragon_egg";
- materials[123] = "minecraft:redstone_lamp";
- materials[125] = "minecraft:double_wooden_slab";
- materials[126] = "minecraft:wooden_slab";
- materials[127] = "minecraft:cocoa";
- materials[128] = "minecraft:sandstone_stairs";
- materials[129] = "minecraft:emerald_ore";
- materials[130] = "minecraft:ender_chest";
- materials[131] = "minecraft:tripwire_hook";
- materials[133] = "minecraft:emerald_block";
- materials[134] = "minecraft:spruce_stairs";
- materials[135] = "minecraft:birch_stairs";
- materials[136] = "minecraft:jungle_stairs";
- materials[137] = "minecraft:command_block";
- materials[138] = "minecraft:beacon";
- materials[139] = "minecraft:cobblestone_wall";
- materials[141] = "minecraft:carrots";
- materials[142] = "minecraft:potatoes";
- materials[143] = "minecraft:wooden_button";
- materials[145] = "minecraft:anvil";
- materials[146] = "minecraft:trapped_chest";
- materials[147] = "minecraft:light_weighted_pressure_plate";
- materials[148] = "minecraft:heavy_weighted_pressure_plate";
- materials[151] = "minecraft:daylight_detector";
- materials[152] = "minecraft:redstone_block";
- materials[153] = "minecraft:quartz_ore";
- materials[154] = "minecraft:hopper";
- materials[155] = "minecraft:quartz_block";
- materials[156] = "minecraft:quartz_stairs";
- materials[157] = "minecraft:activator_rail";
- materials[158] = "minecraft:dropper";
- materials[159] = "minecraft:stained_hardened_clay";
- materials[160] = "minecraft:stained_glass_pane";
- materials[161] = "minecraft:leaves2";
- materials[162] = "minecraft:log2";
- materials[163] = "minecraft:acacia_stairs";
- materials[164] = "minecraft:dark_oak_stairs";
- materials[170] = "minecraft:hay_block";
- materials[171] = "minecraft:carpet";
- materials[172] = "minecraft:hardened_clay";
- materials[173] = "minecraft:coal_block";
- materials[174] = "minecraft:packed_ice";
- materials[175] = "minecraft:double_plant";
- materials[256] = "minecraft:iron_shovel";
- materials[257] = "minecraft:iron_pickaxe";
- materials[258] = "minecraft:iron_axe";
- materials[259] = "minecraft:flint_and_steel";
- materials[260] = "minecraft:apple";
- materials[261] = "minecraft:bow";
- materials[262] = "minecraft:arrow";
- materials[263] = "minecraft:coal";
- materials[264] = "minecraft:diamond";
- materials[265] = "minecraft:iron_ingot";
- materials[266] = "minecraft:gold_ingot";
- materials[267] = "minecraft:iron_sword";
- materials[268] = "minecraft:wooden_sword";
- materials[269] = "minecraft:wooden_shovel";
- materials[270] = "minecraft:wooden_pickaxe";
- materials[271] = "minecraft:wooden_axe";
- materials[272] = "minecraft:stone_sword";
- materials[273] = "minecraft:stone_shovel";
- materials[274] = "minecraft:stone_pickaxe";
- materials[275] = "minecraft:stone_axe";
- materials[276] = "minecraft:diamond_sword";
- materials[277] = "minecraft:diamond_shovel";
- materials[278] = "minecraft:diamond_pickaxe";
- materials[279] = "minecraft:diamond_axe";
- materials[280] = "minecraft:stick";
- materials[281] = "minecraft:bowl";
- materials[282] = "minecraft:mushroom_stew";
- materials[283] = "minecraft:golden_sword";
- materials[284] = "minecraft:golden_shovel";
- materials[285] = "minecraft:golden_pickaxe";
- materials[286] = "minecraft:golden_axe";
- materials[287] = "minecraft:string";
- materials[288] = "minecraft:feather";
- materials[289] = "minecraft:gunpowder";
- materials[290] = "minecraft:wooden_hoe";
- materials[291] = "minecraft:stone_hoe";
- materials[292] = "minecraft:iron_hoe";
- materials[293] = "minecraft:diamond_hoe";
- materials[294] = "minecraft:golden_hoe";
- materials[295] = "minecraft:wheat_seeds";
- materials[296] = "minecraft:wheat";
- materials[297] = "minecraft:bread";
- materials[298] = "minecraft:leather_helmet";
- materials[299] = "minecraft:leather_chestplate";
- materials[300] = "minecraft:leather_leggings";
- materials[301] = "minecraft:leather_boots";
- materials[302] = "minecraft:chainmail_helmet";
- materials[303] = "minecraft:chainmail_chestplate";
- materials[304] = "minecraft:chainmail_leggings";
- materials[305] = "minecraft:chainmail_boots";
- materials[306] = "minecraft:iron_helmet";
- materials[307] = "minecraft:iron_chestplate";
- materials[308] = "minecraft:iron_leggings";
- materials[309] = "minecraft:iron_boots";
- materials[310] = "minecraft:diamond_helmet";
- materials[311] = "minecraft:diamond_chestplate";
- materials[312] = "minecraft:diamond_leggings";
- materials[313] = "minecraft:diamond_boots";
- materials[314] = "minecraft:golden_helmet";
- materials[315] = "minecraft:golden_chestplate";
- materials[316] = "minecraft:golden_leggings";
- materials[317] = "minecraft:golden_boots";
- materials[318] = "minecraft:flint";
- materials[319] = "minecraft:porkchop";
- materials[320] = "minecraft:cooked_porkchop";
- materials[321] = "minecraft:painting";
- materials[322] = "minecraft:golden_apple";
- materials[323] = "minecraft:sign";
- materials[324] = "minecraft:wooden_door";
- materials[325] = "minecraft:bucket";
- materials[326] = "minecraft:water_bucket";
- materials[327] = "minecraft:lava_bucket";
- materials[328] = "minecraft:minecart";
- materials[329] = "minecraft:saddle";
- materials[330] = "minecraft:iron_door";
- materials[331] = "minecraft:redstone";
- materials[332] = "minecraft:snowball";
- materials[333] = "minecraft:boat";
- materials[334] = "minecraft:leather";
- materials[335] = "minecraft:milk_bucket";
- materials[336] = "minecraft:brick";
- materials[337] = "minecraft:clay_ball";
- materials[338] = "minecraft:reeds";
- materials[339] = "minecraft:paper";
- materials[340] = "minecraft:book";
- materials[341] = "minecraft:slime_ball";
- materials[342] = "minecraft:chest_minecart";
- materials[343] = "minecraft:furnace_minecart";
- materials[344] = "minecraft:egg";
- materials[345] = "minecraft:compass";
- materials[346] = "minecraft:fishing_rod";
- materials[347] = "minecraft:clock";
- materials[348] = "minecraft:glowstone_dust";
- materials[349] = "minecraft:fish";
- materials[350] = "minecraft:cooked_fish"; // Paper - cooked_fished -> cooked_fish
- materials[351] = "minecraft:dye";
- materials[352] = "minecraft:bone";
- materials[353] = "minecraft:sugar";
- materials[354] = "minecraft:cake";
- materials[355] = "minecraft:bed";
- materials[356] = "minecraft:repeater";
- materials[357] = "minecraft:cookie";
- materials[358] = "minecraft:filled_map";
- materials[359] = "minecraft:shears";
- materials[360] = "minecraft:melon";
- materials[361] = "minecraft:pumpkin_seeds";
- materials[362] = "minecraft:melon_seeds";
- materials[363] = "minecraft:beef";
- materials[364] = "minecraft:cooked_beef";
- materials[365] = "minecraft:chicken";
- materials[366] = "minecraft:cooked_chicken";
- materials[367] = "minecraft:rotten_flesh";
- materials[368] = "minecraft:ender_pearl";
- materials[369] = "minecraft:blaze_rod";
- materials[370] = "minecraft:ghast_tear";
- materials[371] = "minecraft:gold_nugget";
- materials[372] = "minecraft:nether_wart";
- materials[373] = "minecraft:potion";
- materials[374] = "minecraft:glass_bottle";
- materials[375] = "minecraft:spider_eye";
- materials[376] = "minecraft:fermented_spider_eye";
- materials[377] = "minecraft:blaze_powder";
- materials[378] = "minecraft:magma_cream";
- materials[379] = "minecraft:brewing_stand";
- materials[380] = "minecraft:cauldron";
- materials[381] = "minecraft:ender_eye";
- materials[382] = "minecraft:speckled_melon";
- materials[383] = "minecraft:spawn_egg";
- materials[384] = "minecraft:experience_bottle";
- materials[385] = "minecraft:fire_charge";
- materials[386] = "minecraft:writable_book";
- materials[387] = "minecraft:written_book";
- materials[388] = "minecraft:emerald";
- materials[389] = "minecraft:item_frame";
- materials[390] = "minecraft:flower_pot";
- materials[391] = "minecraft:carrot";
- materials[392] = "minecraft:potato";
- materials[393] = "minecraft:baked_potato";
- materials[394] = "minecraft:poisonous_potato";
- materials[395] = "minecraft:map";
- materials[396] = "minecraft:golden_carrot";
- materials[397] = "minecraft:skull";
- materials[398] = "minecraft:carrot_on_a_stick";
- materials[399] = "minecraft:nether_star";
- materials[400] = "minecraft:pumpkin_pie";
- materials[401] = "minecraft:fireworks";
- materials[402] = "minecraft:firework_charge";
- materials[403] = "minecraft:enchanted_book";
- materials[404] = "minecraft:comparator";
- materials[405] = "minecraft:netherbrick";
- materials[406] = "minecraft:quartz";
- materials[407] = "minecraft:tnt_minecart";
- materials[408] = "minecraft:hopper_minecart";
- materials[417] = "minecraft:iron_horse_armor";
- materials[418] = "minecraft:golden_horse_armor";
- materials[419] = "minecraft:diamond_horse_armor";
- materials[420] = "minecraft:lead";
- materials[421] = "minecraft:name_tag";
- materials[422] = "minecraft:command_block_minecart";
- materials[2256] = "minecraft:record_13";
- materials[2257] = "minecraft:record_cat";
- materials[2258] = "minecraft:record_blocks";
- materials[2259] = "minecraft:record_chirp";
- materials[2260] = "minecraft:record_far";
- materials[2261] = "minecraft:record_mall";
- materials[2262] = "minecraft:record_mellohi";
- materials[2263] = "minecraft:record_stal";
- materials[2264] = "minecraft:record_strad";
- materials[2265] = "minecraft:record_ward";
- materials[2266] = "minecraft:record_11";
- materials[2267] = "minecraft:record_wait";
- // Paper start
- materials[409] = "minecraft:prismarine_shard";
- materials[410] = "minecraft:prismarine_crystals";
- materials[411] = "minecraft:rabbit";
- materials[412] = "minecraft:cooked_rabbit";
- materials[413] = "minecraft:rabbit_stew";
- materials[414] = "minecraft:rabbit_foot";
- materials[415] = "minecraft:rabbit_hide";
- materials[416] = "minecraft:armor_stand";
- materials[423] = "minecraft:mutton";
- materials[424] = "minecraft:cooked_mutton";
- materials[425] = "minecraft:banner";
- materials[426] = "minecraft:end_crystal";
- materials[427] = "minecraft:spruce_door";
- materials[428] = "minecraft:birch_door";
- materials[429] = "minecraft:jungle_door";
- materials[430] = "minecraft:acacia_door";
- materials[431] = "minecraft:dark_oak_door";
- materials[432] = "minecraft:chorus_fruit";
- materials[433] = "minecraft:chorus_fruit_popped";
- materials[434] = "minecraft:beetroot";
- materials[435] = "minecraft:beetroot_seeds";
- materials[436] = "minecraft:beetroot_soup";
- materials[437] = "minecraft:dragon_breath";
- materials[438] = "minecraft:splash_potion";
- materials[439] = "minecraft:spectral_arrow";
- materials[440] = "minecraft:tipped_arrow";
- materials[441] = "minecraft:lingering_potion";
- materials[442] = "minecraft:shield";
- materials[443] = "minecraft:elytra";
- materials[444] = "minecraft:spruce_boat";
- materials[445] = "minecraft:birch_boat";
- materials[446] = "minecraft:jungle_boat";
- materials[447] = "minecraft:acacia_boat";
- materials[448] = "minecraft:dark_oak_boat";
- materials[449] = "minecraft:totem_of_undying";
- materials[450] = "minecraft:shulker_shell";
- materials[452] = "minecraft:iron_nugget";
- materials[453] = "minecraft:knowledge_book";
- // Paper end
- }
- }
-
- private static class DataConverterArmorStand implements DataConverter {
-
- DataConverterArmorStand() {
- }
-
- public int getDataVersion() {
- return 147;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("ArmorStand".equals(cmp.getString("id")) && cmp.getBoolean("Silent") && !cmp.getBoolean("Marker")) {
- cmp.remove("Silent");
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterBanner implements DataConverter {
-
- DataConverterBanner() {
- }
-
- public int getDataVersion() {
- return 804;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("minecraft:banner".equals(cmp.getString("id")) && cmp.contains("tag", 10)) {
- CompoundTag nbttagcompound1 = cmp.getCompound("tag");
-
- if (nbttagcompound1.contains("BlockEntityTag", 10)) {
- CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
-
- if (nbttagcompound2.contains("Base", 99)) {
- cmp.putShort("Damage", (short) (nbttagcompound2.getShort("Base") & 15));
- if (nbttagcompound1.contains("display", 10)) {
- CompoundTag nbttagcompound3 = nbttagcompound1.getCompound("display");
-
- if (nbttagcompound3.contains("Lore", 9)) {
- ListTag nbttaglist = nbttagcompound3.getList("Lore", 8);
-
- if (nbttaglist.size() == 1 && "(+NBT)".equals(nbttaglist.getString(0))) {
- return cmp;
- }
- }
- }
-
- nbttagcompound2.remove("Base");
- if (nbttagcompound2.isEmpty()) {
- nbttagcompound1.remove("BlockEntityTag");
- }
-
- if (nbttagcompound1.isEmpty()) {
- cmp.remove("tag");
- }
- }
- }
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterPotionId implements DataConverter {
-
- private static final String[] potions = new String[128];
-
- DataConverterPotionId() {
- }
-
- public int getDataVersion() {
- return 102;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("minecraft:potion".equals(cmp.getString("id"))) {
- CompoundTag nbttagcompound1 = cmp.getCompound("tag");
- short short0 = cmp.getShort("Damage");
-
- if (!nbttagcompound1.contains("Potion", 8)) {
- String s = DataConverterPotionId.potions[short0 & 127];
-
- nbttagcompound1.putString("Potion", s == null ? "minecraft:water" : s);
- cmp.put("tag", nbttagcompound1);
- if ((short0 & 16384) == 16384) {
- cmp.putString("id", "minecraft:splash_potion");
- }
- }
-
- if (short0 != 0) {
- cmp.putShort("Damage", (short) 0);
- }
- }
-
- return cmp;
- }
-
- static {
- DataConverterPotionId.potions[0] = "minecraft:water";
- DataConverterPotionId.potions[1] = "minecraft:regeneration";
- DataConverterPotionId.potions[2] = "minecraft:swiftness";
- DataConverterPotionId.potions[3] = "minecraft:fire_resistance";
- DataConverterPotionId.potions[4] = "minecraft:poison";
- DataConverterPotionId.potions[5] = "minecraft:healing";
- DataConverterPotionId.potions[6] = "minecraft:night_vision";
- DataConverterPotionId.potions[7] = null;
- DataConverterPotionId.potions[8] = "minecraft:weakness";
- DataConverterPotionId.potions[9] = "minecraft:strength";
- DataConverterPotionId.potions[10] = "minecraft:slowness";
- DataConverterPotionId.potions[11] = "minecraft:leaping";
- DataConverterPotionId.potions[12] = "minecraft:harming";
- DataConverterPotionId.potions[13] = "minecraft:water_breathing";
- DataConverterPotionId.potions[14] = "minecraft:invisibility";
- DataConverterPotionId.potions[15] = null;
- DataConverterPotionId.potions[16] = "minecraft:awkward";
- DataConverterPotionId.potions[17] = "minecraft:regeneration";
- DataConverterPotionId.potions[18] = "minecraft:swiftness";
- DataConverterPotionId.potions[19] = "minecraft:fire_resistance";
- DataConverterPotionId.potions[20] = "minecraft:poison";
- DataConverterPotionId.potions[21] = "minecraft:healing";
- DataConverterPotionId.potions[22] = "minecraft:night_vision";
- DataConverterPotionId.potions[23] = null;
- DataConverterPotionId.potions[24] = "minecraft:weakness";
- DataConverterPotionId.potions[25] = "minecraft:strength";
- DataConverterPotionId.potions[26] = "minecraft:slowness";
- DataConverterPotionId.potions[27] = "minecraft:leaping";
- DataConverterPotionId.potions[28] = "minecraft:harming";
- DataConverterPotionId.potions[29] = "minecraft:water_breathing";
- DataConverterPotionId.potions[30] = "minecraft:invisibility";
- DataConverterPotionId.potions[31] = null;
- DataConverterPotionId.potions[32] = "minecraft:thick";
- DataConverterPotionId.potions[33] = "minecraft:strong_regeneration";
- DataConverterPotionId.potions[34] = "minecraft:strong_swiftness";
- DataConverterPotionId.potions[35] = "minecraft:fire_resistance";
- DataConverterPotionId.potions[36] = "minecraft:strong_poison";
- DataConverterPotionId.potions[37] = "minecraft:strong_healing";
- DataConverterPotionId.potions[38] = "minecraft:night_vision";
- DataConverterPotionId.potions[39] = null;
- DataConverterPotionId.potions[40] = "minecraft:weakness";
- DataConverterPotionId.potions[41] = "minecraft:strong_strength";
- DataConverterPotionId.potions[42] = "minecraft:slowness";
- DataConverterPotionId.potions[43] = "minecraft:strong_leaping";
- DataConverterPotionId.potions[44] = "minecraft:strong_harming";
- DataConverterPotionId.potions[45] = "minecraft:water_breathing";
- DataConverterPotionId.potions[46] = "minecraft:invisibility";
- DataConverterPotionId.potions[47] = null;
- DataConverterPotionId.potions[48] = null;
- DataConverterPotionId.potions[49] = "minecraft:strong_regeneration";
- DataConverterPotionId.potions[50] = "minecraft:strong_swiftness";
- DataConverterPotionId.potions[51] = "minecraft:fire_resistance";
- DataConverterPotionId.potions[52] = "minecraft:strong_poison";
- DataConverterPotionId.potions[53] = "minecraft:strong_healing";
- DataConverterPotionId.potions[54] = "minecraft:night_vision";
- DataConverterPotionId.potions[55] = null;
- DataConverterPotionId.potions[56] = "minecraft:weakness";
- DataConverterPotionId.potions[57] = "minecraft:strong_strength";
- DataConverterPotionId.potions[58] = "minecraft:slowness";
- DataConverterPotionId.potions[59] = "minecraft:strong_leaping";
- DataConverterPotionId.potions[60] = "minecraft:strong_harming";
- DataConverterPotionId.potions[61] = "minecraft:water_breathing";
- DataConverterPotionId.potions[62] = "minecraft:invisibility";
- DataConverterPotionId.potions[63] = null;
- DataConverterPotionId.potions[64] = "minecraft:mundane";
- DataConverterPotionId.potions[65] = "minecraft:long_regeneration";
- DataConverterPotionId.potions[66] = "minecraft:long_swiftness";
- DataConverterPotionId.potions[67] = "minecraft:long_fire_resistance";
- DataConverterPotionId.potions[68] = "minecraft:long_poison";
- DataConverterPotionId.potions[69] = "minecraft:healing";
- DataConverterPotionId.potions[70] = "minecraft:long_night_vision";
- DataConverterPotionId.potions[71] = null;
- DataConverterPotionId.potions[72] = "minecraft:long_weakness";
- DataConverterPotionId.potions[73] = "minecraft:long_strength";
- DataConverterPotionId.potions[74] = "minecraft:long_slowness";
- DataConverterPotionId.potions[75] = "minecraft:long_leaping";
- DataConverterPotionId.potions[76] = "minecraft:harming";
- DataConverterPotionId.potions[77] = "minecraft:long_water_breathing";
- DataConverterPotionId.potions[78] = "minecraft:long_invisibility";
- DataConverterPotionId.potions[79] = null;
- DataConverterPotionId.potions[80] = "minecraft:awkward";
- DataConverterPotionId.potions[81] = "minecraft:long_regeneration";
- DataConverterPotionId.potions[82] = "minecraft:long_swiftness";
- DataConverterPotionId.potions[83] = "minecraft:long_fire_resistance";
- DataConverterPotionId.potions[84] = "minecraft:long_poison";
- DataConverterPotionId.potions[85] = "minecraft:healing";
- DataConverterPotionId.potions[86] = "minecraft:long_night_vision";
- DataConverterPotionId.potions[87] = null;
- DataConverterPotionId.potions[88] = "minecraft:long_weakness";
- DataConverterPotionId.potions[89] = "minecraft:long_strength";
- DataConverterPotionId.potions[90] = "minecraft:long_slowness";
- DataConverterPotionId.potions[91] = "minecraft:long_leaping";
- DataConverterPotionId.potions[92] = "minecraft:harming";
- DataConverterPotionId.potions[93] = "minecraft:long_water_breathing";
- DataConverterPotionId.potions[94] = "minecraft:long_invisibility";
- DataConverterPotionId.potions[95] = null;
- DataConverterPotionId.potions[96] = "minecraft:thick";
- DataConverterPotionId.potions[97] = "minecraft:regeneration";
- DataConverterPotionId.potions[98] = "minecraft:swiftness";
- DataConverterPotionId.potions[99] = "minecraft:long_fire_resistance";
- DataConverterPotionId.potions[100] = "minecraft:poison";
- DataConverterPotionId.potions[101] = "minecraft:strong_healing";
- DataConverterPotionId.potions[102] = "minecraft:long_night_vision";
- DataConverterPotionId.potions[103] = null;
- DataConverterPotionId.potions[104] = "minecraft:long_weakness";
- DataConverterPotionId.potions[105] = "minecraft:strength";
- DataConverterPotionId.potions[106] = "minecraft:long_slowness";
- DataConverterPotionId.potions[107] = "minecraft:leaping";
- DataConverterPotionId.potions[108] = "minecraft:strong_harming";
- DataConverterPotionId.potions[109] = "minecraft:long_water_breathing";
- DataConverterPotionId.potions[110] = "minecraft:long_invisibility";
- DataConverterPotionId.potions[111] = null;
- DataConverterPotionId.potions[112] = null;
- DataConverterPotionId.potions[113] = "minecraft:regeneration";
- DataConverterPotionId.potions[114] = "minecraft:swiftness";
- DataConverterPotionId.potions[115] = "minecraft:long_fire_resistance";
- DataConverterPotionId.potions[116] = "minecraft:poison";
- DataConverterPotionId.potions[117] = "minecraft:strong_healing";
- DataConverterPotionId.potions[118] = "minecraft:long_night_vision";
- DataConverterPotionId.potions[119] = null;
- DataConverterPotionId.potions[120] = "minecraft:long_weakness";
- DataConverterPotionId.potions[121] = "minecraft:strength";
- DataConverterPotionId.potions[122] = "minecraft:long_slowness";
- DataConverterPotionId.potions[123] = "minecraft:leaping";
- DataConverterPotionId.potions[124] = "minecraft:strong_harming";
- DataConverterPotionId.potions[125] = "minecraft:long_water_breathing";
- DataConverterPotionId.potions[126] = "minecraft:long_invisibility";
- DataConverterPotionId.potions[127] = null;
- }
- }
-
- private static class DataConverterSpawnEgg implements DataConverter {
-
- private static final String[] eggs = new String[256];
-
- DataConverterSpawnEgg() {
- }
-
- public int getDataVersion() {
- return 105;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("minecraft:spawn_egg".equals(cmp.getString("id"))) {
- CompoundTag nbttagcompound1 = cmp.getCompound("tag");
- CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("EntityTag");
- short short0 = cmp.getShort("Damage");
-
- if (!nbttagcompound2.contains("id", 8)) {
- String s = DataConverterSpawnEgg.eggs[short0 & 255];
-
- if (s != null) {
- nbttagcompound2.putString("id", s);
- nbttagcompound1.put("EntityTag", nbttagcompound2);
- cmp.put("tag", nbttagcompound1);
- }
- }
-
- if (short0 != 0) {
- cmp.putShort("Damage", (short) 0);
- }
- }
-
- return cmp;
- }
-
- static {
-
- DataConverterSpawnEgg.eggs[1] = "Item";
- DataConverterSpawnEgg.eggs[2] = "XPOrb";
- DataConverterSpawnEgg.eggs[7] = "ThrownEgg";
- DataConverterSpawnEgg.eggs[8] = "LeashKnot";
- DataConverterSpawnEgg.eggs[9] = "Painting";
- DataConverterSpawnEgg.eggs[10] = "Arrow";
- DataConverterSpawnEgg.eggs[11] = "Snowball";
- DataConverterSpawnEgg.eggs[12] = "Fireball";
- DataConverterSpawnEgg.eggs[13] = "SmallFireball";
- DataConverterSpawnEgg.eggs[14] = "ThrownEnderpearl";
- DataConverterSpawnEgg.eggs[15] = "EyeOfEnderSignal";
- DataConverterSpawnEgg.eggs[16] = "ThrownPotion";
- DataConverterSpawnEgg.eggs[17] = "ThrownExpBottle";
- DataConverterSpawnEgg.eggs[18] = "ItemFrame";
- DataConverterSpawnEgg.eggs[19] = "WitherSkull";
- DataConverterSpawnEgg.eggs[20] = "PrimedTnt";
- DataConverterSpawnEgg.eggs[21] = "FallingSand";
- DataConverterSpawnEgg.eggs[22] = "FireworksRocketEntity";
- DataConverterSpawnEgg.eggs[23] = "TippedArrow";
- DataConverterSpawnEgg.eggs[24] = "SpectralArrow";
- DataConverterSpawnEgg.eggs[25] = "ShulkerBullet";
- DataConverterSpawnEgg.eggs[26] = "DragonFireball";
- DataConverterSpawnEgg.eggs[30] = "ArmorStand";
- DataConverterSpawnEgg.eggs[41] = "Boat";
- DataConverterSpawnEgg.eggs[42] = "MinecartRideable";
- DataConverterSpawnEgg.eggs[43] = "MinecartChest";
- DataConverterSpawnEgg.eggs[44] = "MinecartFurnace";
- DataConverterSpawnEgg.eggs[45] = "MinecartTNT";
- DataConverterSpawnEgg.eggs[46] = "MinecartHopper";
- DataConverterSpawnEgg.eggs[47] = "MinecartSpawner";
- DataConverterSpawnEgg.eggs[40] = "MinecartCommandBlock";
- DataConverterSpawnEgg.eggs[48] = "Mob";
- DataConverterSpawnEgg.eggs[49] = "Monster";
- DataConverterSpawnEgg.eggs[50] = "Creeper";
- DataConverterSpawnEgg.eggs[51] = "Skeleton";
- DataConverterSpawnEgg.eggs[52] = "Spider";
- DataConverterSpawnEgg.eggs[53] = "Giant";
- DataConverterSpawnEgg.eggs[54] = "Zombie";
- DataConverterSpawnEgg.eggs[55] = "Slime";
- DataConverterSpawnEgg.eggs[56] = "Ghast";
- DataConverterSpawnEgg.eggs[57] = "PigZombie";
- DataConverterSpawnEgg.eggs[58] = "Enderman";
- DataConverterSpawnEgg.eggs[59] = "CaveSpider";
- DataConverterSpawnEgg.eggs[60] = "Silverfish";
- DataConverterSpawnEgg.eggs[61] = "Blaze";
- DataConverterSpawnEgg.eggs[62] = "LavaSlime";
- DataConverterSpawnEgg.eggs[63] = "EnderDragon";
- DataConverterSpawnEgg.eggs[64] = "WitherBoss";
- DataConverterSpawnEgg.eggs[65] = "Bat";
- DataConverterSpawnEgg.eggs[66] = "Witch";
- DataConverterSpawnEgg.eggs[67] = "Endermite";
- DataConverterSpawnEgg.eggs[68] = "Guardian";
- DataConverterSpawnEgg.eggs[69] = "Shulker";
- DataConverterSpawnEgg.eggs[90] = "Pig";
- DataConverterSpawnEgg.eggs[91] = "Sheep";
- DataConverterSpawnEgg.eggs[92] = "Cow";
- DataConverterSpawnEgg.eggs[93] = "Chicken";
- DataConverterSpawnEgg.eggs[94] = "Squid";
- DataConverterSpawnEgg.eggs[95] = "Wolf";
- DataConverterSpawnEgg.eggs[96] = "MushroomCow";
- DataConverterSpawnEgg.eggs[97] = "SnowMan";
- DataConverterSpawnEgg.eggs[98] = "Ozelot";
- DataConverterSpawnEgg.eggs[99] = "VillagerGolem";
- DataConverterSpawnEgg.eggs[100] = "EntityHorse";
- DataConverterSpawnEgg.eggs[101] = "Rabbit";
- DataConverterSpawnEgg.eggs[120] = "Villager";
- DataConverterSpawnEgg.eggs[200] = "EnderCrystal";
- }
- }
-
- private static class DataConverterMinecart implements DataConverter {
-
- private static final List a = Lists.newArrayList("MinecartRideable", "MinecartChest", "MinecartFurnace", "MinecartTNT", "MinecartSpawner", "MinecartHopper", "MinecartCommandBlock");
-
- DataConverterMinecart() {
- }
-
- public int getDataVersion() {
- return 106;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("Minecart".equals(cmp.getString("id"))) {
- String s = "MinecartRideable";
- int i = cmp.getInt("Type");
-
- if (i > 0 && i < DataConverterMinecart.a.size()) {
- s = DataConverterMinecart.a.get(i);
- }
-
- cmp.putString("id", s);
- cmp.remove("Type");
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterMobSpawner implements DataConverter {
-
- DataConverterMobSpawner() {
- }
-
- public int getDataVersion() {
- return 107;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if (!"MobSpawner".equals(cmp.getString("id"))) {
- return cmp;
- } else {
- if (cmp.contains("EntityId", 8)) {
- String s = cmp.getString("EntityId");
- CompoundTag nbttagcompound1 = cmp.getCompound("SpawnData");
-
- nbttagcompound1.putString("id", s.isEmpty() ? "Pig" : s);
- cmp.put("SpawnData", nbttagcompound1);
- cmp.remove("EntityId");
- }
-
- if (cmp.contains("SpawnPotentials", 9)) {
- ListTag nbttaglist = cmp.getList("SpawnPotentials", 10);
-
- for (int i = 0; i < nbttaglist.size(); ++i) {
- CompoundTag nbttagcompound2 = nbttaglist.getCompound(i);
-
- if (nbttagcompound2.contains("Type", 8)) {
- CompoundTag nbttagcompound3 = nbttagcompound2.getCompound("Properties");
-
- nbttagcompound3.putString("id", nbttagcompound2.getString("Type"));
- nbttagcompound2.put("Entity", nbttagcompound3);
- nbttagcompound2.remove("Type");
- nbttagcompound2.remove("Properties");
- }
- }
- }
-
- return cmp;
- }
- }
- }
-
- private static class DataConverterUUID implements DataConverter {
-
- DataConverterUUID() {
- }
-
- public int getDataVersion() {
- return 108;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if (cmp.contains("UUID", 8)) {
- cmp.putUUID("UUID", UUID.fromString(cmp.getString("UUID")));
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterHealth implements DataConverter {
-
- private static final Set a = Sets.newHashSet("ArmorStand", "Bat", "Blaze", "CaveSpider", "Chicken", "Cow", "Creeper", "EnderDragon", "Enderman", "Endermite", "EntityHorse", "Ghast", "Giant", "Guardian", "LavaSlime", "MushroomCow", "Ozelot", "Pig", "PigZombie", "Rabbit", "Sheep", "Shulker", "Silverfish", "Skeleton", "Slime", "SnowMan", "Spider", "Squid", "Villager", "VillagerGolem", "Witch", "WitherBoss", "Wolf", "Zombie");
-
- DataConverterHealth() {
- }
-
- public int getDataVersion() {
- return 109;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if (DataConverterHealth.a.contains(cmp.getString("id"))) {
- float f;
-
- if (cmp.contains("HealF", 99)) {
- f = cmp.getFloat("HealF");
- cmp.remove("HealF");
- } else {
- if (!cmp.contains("Health", 99)) {
- return cmp;
- }
-
- f = cmp.getFloat("Health");
- }
-
- cmp.putFloat("Health", f);
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterSaddle implements DataConverter {
-
- DataConverterSaddle() {
- }
-
- public int getDataVersion() {
- return 110;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("EntityHorse".equals(cmp.getString("id")) && !cmp.contains("SaddleItem", 10) && cmp.getBoolean("Saddle")) {
- CompoundTag nbttagcompound1 = new CompoundTag();
-
- nbttagcompound1.putString("id", "minecraft:saddle");
- nbttagcompound1.putByte("Count", (byte) 1);
- nbttagcompound1.putShort("Damage", (short) 0);
- cmp.put("SaddleItem", nbttagcompound1);
- cmp.remove("Saddle");
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterHanging implements DataConverter {
-
- DataConverterHanging() {
- }
-
- public int getDataVersion() {
- return 111;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- String s = cmp.getString("id");
- boolean flag = "Painting".equals(s);
- boolean flag1 = "ItemFrame".equals(s);
-
- if ((flag || flag1) && !cmp.contains("Facing", 99)) {
- Direction enumdirection;
-
- if (cmp.contains("Direction", 99)) {
- enumdirection = Direction.from2DDataValue(cmp.getByte("Direction"));
- cmp.putInt("TileX", cmp.getInt("TileX") + enumdirection.getStepX());
- cmp.putInt("TileY", cmp.getInt("TileY") + enumdirection.getStepY());
- cmp.putInt("TileZ", cmp.getInt("TileZ") + enumdirection.getStepZ());
- cmp.remove("Direction");
- if (flag1 && cmp.contains("ItemRotation", 99)) {
- cmp.putByte("ItemRotation", (byte) (cmp.getByte("ItemRotation") * 2));
- }
- } else {
- enumdirection = Direction.from2DDataValue(cmp.getByte("Dir"));
- cmp.remove("Dir");
- }
-
- cmp.putByte("Facing", (byte) enumdirection.get2DDataValue());
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterDropChances implements DataConverter {
-
- DataConverterDropChances() {
- }
-
- public int getDataVersion() {
- return 113;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- ListTag nbttaglist;
-
- if (cmp.contains("HandDropChances", 9)) {
- nbttaglist = cmp.getList("HandDropChances", 5);
- if (nbttaglist.size() == 2 && nbttaglist.getFloat(0) == 0.0F && nbttaglist.getFloat(1) == 0.0F) {
- cmp.remove("HandDropChances");
- }
- }
-
- if (cmp.contains("ArmorDropChances", 9)) {
- nbttaglist = cmp.getList("ArmorDropChances", 5);
- if (nbttaglist.size() == 4 && nbttaglist.getFloat(0) == 0.0F && nbttaglist.getFloat(1) == 0.0F && nbttaglist.getFloat(2) == 0.0F && nbttaglist.getFloat(3) == 0.0F) {
- cmp.remove("ArmorDropChances");
- }
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterRiding implements DataConverter {
-
- DataConverterRiding() {
- }
-
- public int getDataVersion() {
- return 135;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- while (cmp.contains("Riding", 10)) {
- CompoundTag nbttagcompound1 = this.b(cmp);
-
- this.convert(cmp, nbttagcompound1);
- cmp = nbttagcompound1;
- }
-
- return cmp;
- }
-
- protected void convert(CompoundTag nbttagcompound, CompoundTag nbttagcompound1) {
- ListTag nbttaglist = new ListTag();
-
- nbttaglist.add(nbttagcompound);
- nbttagcompound1.put("Passengers", nbttaglist);
- }
-
- protected CompoundTag b(CompoundTag nbttagcompound) {
- CompoundTag nbttagcompound1 = nbttagcompound.getCompound("Riding");
-
- nbttagcompound.remove("Riding");
- return nbttagcompound1;
- }
- }
-
- private static class DataConverterBook implements DataConverter {
-
- DataConverterBook() {
- }
-
- public int getDataVersion() {
- return 165;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("minecraft:written_book".equals(cmp.getString("id"))) {
- CompoundTag nbttagcompound1 = cmp.getCompound("tag");
-
- if (nbttagcompound1.contains("pages", 9)) {
- ListTag nbttaglist = nbttagcompound1.getList("pages", 8);
-
- for (int i = 0; i < nbttaglist.size(); ++i) {
- String s = nbttaglist.getString(i);
- Component object = null;
-
- if (!"null".equals(s) && !StringUtil.isNullOrEmpty(s)) {
- if ((s.charAt(0) != 34 || s.charAt(s.length() - 1) != 34) && (s.charAt(0) != 123 || s.charAt(s.length() - 1) != 125)) {
- object = new TextComponent(s);
- } else {
- try {
- object = GsonHelper.fromJson(DataConverterSignText.a, s, Component.class, true);
- if (object == null) {
- object = new TextComponent("");
- }
- } catch (JsonParseException jsonparseexception) {
- ;
- }
-
- if (object == null) {
- try {
- object = Component.Serializer.fromJson(s);
- } catch (JsonParseException jsonparseexception1) {
- ;
- }
- }
-
- if (object == null) {
- try {
- object = Component.Serializer.fromJsonLenient(s);
- } catch (JsonParseException jsonparseexception2) {
- ;
- }
- }
-
- if (object == null) {
- object = new TextComponent(s);
- }
- }
- } else {
- object = new TextComponent("");
- }
-
- nbttaglist.set(i, StringTag.valueOf(Component.Serializer.toJson(object)));
- }
-
- nbttagcompound1.put("pages", nbttaglist);
- }
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterCookedFish implements DataConverter {
-
- private static final ResourceLocation a = new ResourceLocation("cooked_fished");
-
- DataConverterCookedFish() {
- }
-
- public int getDataVersion() {
- return 502;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if (cmp.contains("id", 8) && DataConverterCookedFish.a.equals(new ResourceLocation(cmp.getString("id")))) {
- cmp.putString("id", "minecraft:cooked_fish");
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterZombie implements DataConverter {
-
- private static final Random a = new Random();
-
- DataConverterZombie() {
- }
-
- public int getDataVersion() {
- return 502;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("Zombie".equals(cmp.getString("id")) && cmp.getBoolean("IsVillager")) {
- if (!cmp.contains("ZombieType", 99)) {
- int i = -1;
-
- if (cmp.contains("VillagerProfession", 99)) {
- try {
- i = this.convert(cmp.getInt("VillagerProfession"));
- } catch (RuntimeException runtimeexception) {
- ;
- }
- }
-
- if (i == -1) {
- i = this.convert(DataConverterZombie.a.nextInt(6));
- }
-
- cmp.putInt("ZombieType", i);
- }
-
- cmp.remove("IsVillager");
- }
-
- return cmp;
- }
-
- private int convert(int i) {
- return i >= 0 && i < 6 ? i : -1;
- }
- }
-
- private static class DataConverterVBO implements DataConverter {
-
- DataConverterVBO() {
- }
-
- public int getDataVersion() {
- return 505;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- cmp.putString("useVbo", "true");
- return cmp;
- }
- }
-
- private static class DataConverterGuardian implements DataConverter {
-
- DataConverterGuardian() {
- }
-
- public int getDataVersion() {
- return 700;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("Guardian".equals(cmp.getString("id"))) {
- if (cmp.getBoolean("Elder")) {
- cmp.putString("id", "ElderGuardian");
- }
-
- cmp.remove("Elder");
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterSkeleton implements DataConverter {
-
- DataConverterSkeleton() {
- }
-
- public int getDataVersion() {
- return 701;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- String s = cmp.getString("id");
-
- if ("Skeleton".equals(s)) {
- int i = cmp.getInt("SkeletonType");
-
- if (i == 1) {
- cmp.putString("id", "WitherSkeleton");
- } else if (i == 2) {
- cmp.putString("id", "Stray");
- }
-
- cmp.remove("SkeletonType");
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterZombieType implements DataConverter {
-
- DataConverterZombieType() {
- }
-
- public int getDataVersion() {
- return 702;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("Zombie".equals(cmp.getString("id"))) {
- int i = cmp.getInt("ZombieType");
-
- switch (i) {
- case 0:
- default:
- break;
-
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- cmp.putString("id", "ZombieVillager");
- cmp.putInt("Profession", i - 1);
- break;
-
- case 6:
- cmp.putString("id", "Husk");
- }
-
- cmp.remove("ZombieType");
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterHorse implements DataConverter {
-
- DataConverterHorse() {
- }
-
- public int getDataVersion() {
- return 703;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("EntityHorse".equals(cmp.getString("id"))) {
- int i = cmp.getInt("Type");
-
- switch (i) {
- case 0:
- default:
- cmp.putString("id", "Horse");
- break;
-
- case 1:
- cmp.putString("id", "Donkey");
- break;
-
- case 2:
- cmp.putString("id", "Mule");
- break;
-
- case 3:
- cmp.putString("id", "ZombieHorse");
- break;
-
- case 4:
- cmp.putString("id", "SkeletonHorse");
- }
-
- cmp.remove("Type");
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterTileEntity implements DataConverter {
-
- private static final Map a = Maps.newHashMap();
-
- DataConverterTileEntity() {
- }
-
- public int getDataVersion() {
- return 704;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- String s = DataConverterTileEntity.a.get(cmp.getString("id"));
-
- if (s != null) {
- cmp.putString("id", s);
- }
-
- return cmp;
- }
-
- static {
- DataConverterTileEntity.a.put("Airportal", "minecraft:end_portal");
- DataConverterTileEntity.a.put("Banner", "minecraft:banner");
- DataConverterTileEntity.a.put("Beacon", "minecraft:beacon");
- DataConverterTileEntity.a.put("Cauldron", "minecraft:brewing_stand");
- DataConverterTileEntity.a.put("Chest", "minecraft:chest");
- DataConverterTileEntity.a.put("Comparator", "minecraft:comparator");
- DataConverterTileEntity.a.put("Control", "minecraft:command_block");
- DataConverterTileEntity.a.put("DLDetector", "minecraft:daylight_detector");
- DataConverterTileEntity.a.put("Dropper", "minecraft:dropper");
- DataConverterTileEntity.a.put("EnchantTable", "minecraft:enchanting_table");
- DataConverterTileEntity.a.put("EndGateway", "minecraft:end_gateway");
- DataConverterTileEntity.a.put("EnderChest", "minecraft:ender_chest");
- DataConverterTileEntity.a.put("FlowerPot", "minecraft:flower_pot");
- DataConverterTileEntity.a.put("Furnace", "minecraft:furnace");
- DataConverterTileEntity.a.put("Hopper", "minecraft:hopper");
- DataConverterTileEntity.a.put("MobSpawner", "minecraft:mob_spawner");
- DataConverterTileEntity.a.put("Music", "minecraft:noteblock");
- DataConverterTileEntity.a.put("Piston", "minecraft:piston");
- DataConverterTileEntity.a.put("RecordPlayer", "minecraft:jukebox");
- DataConverterTileEntity.a.put("Sign", "minecraft:sign");
- DataConverterTileEntity.a.put("Skull", "minecraft:skull");
- DataConverterTileEntity.a.put("Structure", "minecraft:structure_block");
- DataConverterTileEntity.a.put("Trap", "minecraft:dispenser");
- }
- }
-
- private static class DataConverterEntity implements DataConverter {
-
- private static final Map a = Maps.newHashMap();
-
- DataConverterEntity() {
- }
-
- public int getDataVersion() {
- return 704;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- String s = DataConverterEntity.a.get(cmp.getString("id"));
-
- if (s != null) {
- cmp.putString("id", s);
- }
-
- return cmp;
- }
-
- static {
- DataConverterEntity.a.put("AreaEffectCloud", "minecraft:area_effect_cloud");
- DataConverterEntity.a.put("ArmorStand", "minecraft:armor_stand");
- DataConverterEntity.a.put("Arrow", "minecraft:arrow");
- DataConverterEntity.a.put("Bat", "minecraft:bat");
- DataConverterEntity.a.put("Blaze", "minecraft:blaze");
- DataConverterEntity.a.put("Boat", "minecraft:boat");
- DataConverterEntity.a.put("CaveSpider", "minecraft:cave_spider");
- DataConverterEntity.a.put("Chicken", "minecraft:chicken");
- DataConverterEntity.a.put("Cow", "minecraft:cow");
- DataConverterEntity.a.put("Creeper", "minecraft:creeper");
- DataConverterEntity.a.put("Donkey", "minecraft:donkey");
- DataConverterEntity.a.put("DragonFireball", "minecraft:dragon_fireball");
- DataConverterEntity.a.put("ElderGuardian", "minecraft:elder_guardian");
- DataConverterEntity.a.put("EnderCrystal", "minecraft:ender_crystal");
- DataConverterEntity.a.put("EnderDragon", "minecraft:ender_dragon");
- DataConverterEntity.a.put("Enderman", "minecraft:enderman");
- DataConverterEntity.a.put("Endermite", "minecraft:endermite");
- DataConverterEntity.a.put("EyeOfEnderSignal", "minecraft:eye_of_ender_signal");
- DataConverterEntity.a.put("FallingSand", "minecraft:falling_block");
- DataConverterEntity.a.put("Fireball", "minecraft:fireball");
- DataConverterEntity.a.put("FireworksRocketEntity", "minecraft:fireworks_rocket");
- DataConverterEntity.a.put("Ghast", "minecraft:ghast");
- DataConverterEntity.a.put("Giant", "minecraft:giant");
- DataConverterEntity.a.put("Guardian", "minecraft:guardian");
- DataConverterEntity.a.put("Horse", "minecraft:horse");
- DataConverterEntity.a.put("Husk", "minecraft:husk");
- DataConverterEntity.a.put("Item", "minecraft:item");
- DataConverterEntity.a.put("ItemFrame", "minecraft:item_frame");
- DataConverterEntity.a.put("LavaSlime", "minecraft:magma_cube");
- DataConverterEntity.a.put("LeashKnot", "minecraft:leash_knot");
- DataConverterEntity.a.put("MinecartChest", "minecraft:chest_minecart");
- DataConverterEntity.a.put("MinecartCommandBlock", "minecraft:commandblock_minecart");
- DataConverterEntity.a.put("MinecartFurnace", "minecraft:furnace_minecart");
- DataConverterEntity.a.put("MinecartHopper", "minecraft:hopper_minecart");
- DataConverterEntity.a.put("MinecartRideable", "minecraft:minecart");
- DataConverterEntity.a.put("MinecartSpawner", "minecraft:spawner_minecart");
- DataConverterEntity.a.put("MinecartTNT", "minecraft:tnt_minecart");
- DataConverterEntity.a.put("Mule", "minecraft:mule");
- DataConverterEntity.a.put("MushroomCow", "minecraft:mooshroom");
- DataConverterEntity.a.put("Ozelot", "minecraft:ocelot");
- DataConverterEntity.a.put("Painting", "minecraft:painting");
- DataConverterEntity.a.put("Pig", "minecraft:pig");
- DataConverterEntity.a.put("PigZombie", "minecraft:zombie_pigman");
- DataConverterEntity.a.put("PolarBear", "minecraft:polar_bear");
- DataConverterEntity.a.put("PrimedTnt", "minecraft:tnt");
- DataConverterEntity.a.put("Rabbit", "minecraft:rabbit");
- DataConverterEntity.a.put("Sheep", "minecraft:sheep");
- DataConverterEntity.a.put("Shulker", "minecraft:shulker");
- DataConverterEntity.a.put("ShulkerBullet", "minecraft:shulker_bullet");
- DataConverterEntity.a.put("Silverfish", "minecraft:silverfish");
- DataConverterEntity.a.put("Skeleton", "minecraft:skeleton");
- DataConverterEntity.a.put("SkeletonHorse", "minecraft:skeleton_horse");
- DataConverterEntity.a.put("Slime", "minecraft:slime");
- DataConverterEntity.a.put("SmallFireball", "minecraft:small_fireball");
- DataConverterEntity.a.put("SnowMan", "minecraft:snowman");
- DataConverterEntity.a.put("Snowball", "minecraft:snowball");
- DataConverterEntity.a.put("SpectralArrow", "minecraft:spectral_arrow");
- DataConverterEntity.a.put("Spider", "minecraft:spider");
- DataConverterEntity.a.put("Squid", "minecraft:squid");
- DataConverterEntity.a.put("Stray", "minecraft:stray");
- DataConverterEntity.a.put("ThrownEgg", "minecraft:egg");
- DataConverterEntity.a.put("ThrownEnderpearl", "minecraft:ender_pearl");
- DataConverterEntity.a.put("ThrownExpBottle", "minecraft:xp_bottle");
- DataConverterEntity.a.put("ThrownPotion", "minecraft:potion");
- DataConverterEntity.a.put("Villager", "minecraft:villager");
- DataConverterEntity.a.put("VillagerGolem", "minecraft:villager_golem");
- DataConverterEntity.a.put("Witch", "minecraft:witch");
- DataConverterEntity.a.put("WitherBoss", "minecraft:wither");
- DataConverterEntity.a.put("WitherSkeleton", "minecraft:wither_skeleton");
- DataConverterEntity.a.put("WitherSkull", "minecraft:wither_skull");
- DataConverterEntity.a.put("Wolf", "minecraft:wolf");
- DataConverterEntity.a.put("XPOrb", "minecraft:xp_orb");
- DataConverterEntity.a.put("Zombie", "minecraft:zombie");
- DataConverterEntity.a.put("ZombieHorse", "minecraft:zombie_horse");
- DataConverterEntity.a.put("ZombieVillager", "minecraft:zombie_villager");
- }
- }
-
- private static class DataConverterPotionWater implements DataConverter {
-
- DataConverterPotionWater() {
- }
-
- public int getDataVersion() {
- return 806;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- String s = cmp.getString("id");
-
- if ("minecraft:potion".equals(s) || "minecraft:splash_potion".equals(s) || "minecraft:lingering_potion".equals(s) || "minecraft:tipped_arrow".equals(s)) {
- CompoundTag nbttagcompound1 = cmp.getCompound("tag");
-
- if (!nbttagcompound1.contains("Potion", 8)) {
- nbttagcompound1.putString("Potion", "minecraft:water");
- }
-
- if (!cmp.contains("tag", 10)) {
- cmp.put("tag", nbttagcompound1);
- }
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterShulker implements DataConverter {
-
- DataConverterShulker() {
- }
-
- public int getDataVersion() {
- return 808;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("minecraft:shulker".equals(cmp.getString("id")) && !cmp.contains("Color", 99)) {
- cmp.putByte("Color", (byte) 10);
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterShulkerBoxItem implements DataConverter {
-
- public static final String[] a = new String[] { "minecraft:white_shulker_box", "minecraft:orange_shulker_box", "minecraft:magenta_shulker_box", "minecraft:light_blue_shulker_box", "minecraft:yellow_shulker_box", "minecraft:lime_shulker_box", "minecraft:pink_shulker_box", "minecraft:gray_shulker_box", "minecraft:silver_shulker_box", "minecraft:cyan_shulker_box", "minecraft:purple_shulker_box", "minecraft:blue_shulker_box", "minecraft:brown_shulker_box", "minecraft:green_shulker_box", "minecraft:red_shulker_box", "minecraft:black_shulker_box" };
-
- DataConverterShulkerBoxItem() {
- }
-
- public int getDataVersion() {
- return 813;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("minecraft:shulker_box".equals(cmp.getString("id")) && cmp.contains("tag", 10)) {
- CompoundTag nbttagcompound1 = cmp.getCompound("tag");
-
- if (nbttagcompound1.contains("BlockEntityTag", 10)) {
- CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
-
- if (nbttagcompound2.getList("Items", 10).isEmpty()) {
- nbttagcompound2.remove("Items");
- }
-
- int i = nbttagcompound2.getInt("Color");
-
- nbttagcompound2.remove("Color");
- if (nbttagcompound2.isEmpty()) {
- nbttagcompound1.remove("BlockEntityTag");
- }
-
- if (nbttagcompound1.isEmpty()) {
- cmp.remove("tag");
- }
-
- cmp.putString("id", DataConverterShulkerBoxItem.a[i % 16]);
- }
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterShulkerBoxBlock implements DataConverter {
-
- DataConverterShulkerBoxBlock() {
- }
-
- public int getDataVersion() {
- return 813;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("minecraft:shulker".equals(cmp.getString("id"))) {
- cmp.remove("Color");
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterLang implements DataConverter {
-
- DataConverterLang() {
- }
-
- public int getDataVersion() {
- return 816;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if (cmp.contains("lang", 8)) {
- cmp.putString("lang", cmp.getString("lang").toLowerCase(Locale.ROOT));
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterTotem implements DataConverter {
-
- DataConverterTotem() {
- }
-
- public int getDataVersion() {
- return 820;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("minecraft:totem".equals(cmp.getString("id"))) {
- cmp.putString("id", "minecraft:totem_of_undying");
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterBedBlock implements DataConverter {
-
- private static final Logger a = LogManager.getLogger(PaperweightDataConverters.class);
-
- DataConverterBedBlock() {
- }
-
- public int getDataVersion() {
- return 1125;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- try {
- CompoundTag nbttagcompound1 = cmp.getCompound("Level");
- int i = nbttagcompound1.getInt("xPos");
- int j = nbttagcompound1.getInt("zPos");
- ListTag nbttaglist = nbttagcompound1.getList("TileEntities", 10);
- ListTag nbttaglist1 = nbttagcompound1.getList("Sections", 10);
-
- for (int k = 0; k < nbttaglist1.size(); ++k) {
- CompoundTag nbttagcompound2 = nbttaglist1.getCompound(k);
- byte b0 = nbttagcompound2.getByte("Y");
- byte[] abyte = nbttagcompound2.getByteArray("Blocks");
-
- for (int l = 0; l < abyte.length; ++l) {
- if (416 == (abyte[l] & 255) << 4) {
- int i1 = l & 15;
- int j1 = l >> 8 & 15;
- int k1 = l >> 4 & 15;
- CompoundTag nbttagcompound3 = new CompoundTag();
-
- nbttagcompound3.putString("id", "bed");
- nbttagcompound3.putInt("x", i1 + (i << 4));
- nbttagcompound3.putInt("y", j1 + (b0 << 4));
- nbttagcompound3.putInt("z", k1 + (j << 4));
- nbttaglist.add(nbttagcompound3);
- }
- }
- }
- } catch (Exception exception) {
- DataConverterBedBlock.a.warn("Unable to datafix Bed blocks, level format may be missing tags.");
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterBedItem implements DataConverter {
-
- DataConverterBedItem() {
- }
-
- public int getDataVersion() {
- return 1125;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("minecraft:bed".equals(cmp.getString("id")) && cmp.getShort("Damage") == 0) {
- cmp.putShort("Damage", (short) DyeColor.RED.getId());
- }
-
- return cmp;
- }
- }
-
- private static class DataConverterSignText implements DataConverter {
-
- public static final Gson a = new GsonBuilder().registerTypeAdapter(Component.class, new JsonDeserializer() {
- MutableComponent a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
- if (jsonelement.isJsonPrimitive()) {
- return new TextComponent(jsonelement.getAsString());
- } else if (jsonelement.isJsonArray()) {
- JsonArray jsonarray = jsonelement.getAsJsonArray();
- MutableComponent ichatbasecomponent = null;
- Iterator iterator = jsonarray.iterator();
-
- while (iterator.hasNext()) {
- JsonElement jsonelement1 = (JsonElement) iterator.next();
- MutableComponent ichatbasecomponent1 = this.a(jsonelement1, jsonelement1.getClass(), jsondeserializationcontext);
-
- if (ichatbasecomponent == null) {
- ichatbasecomponent = ichatbasecomponent1;
- } else {
- ichatbasecomponent.append(ichatbasecomponent1);
- }
- }
-
- return ichatbasecomponent;
- } else {
- throw new JsonParseException("Don't know how to turn " + jsonelement + " into a Component");
- }
- }
-
- public Object deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
- return this.a(jsonelement, type, jsondeserializationcontext);
- }
- }).create();
-
- DataConverterSignText() {
- }
-
- public int getDataVersion() {
- return 101;
- }
-
- public CompoundTag convert(CompoundTag cmp) {
- if ("Sign".equals(cmp.getString("id"))) {
- this.convert(cmp, "Text1");
- this.convert(cmp, "Text2");
- this.convert(cmp, "Text3");
- this.convert(cmp, "Text4");
- }
-
- return cmp;
- }
-
- private void convert(CompoundTag nbttagcompound, String s) {
- String s1 = nbttagcompound.getString(s);
- Component object = null;
-
- if (!"null".equals(s1) && !StringUtil.isNullOrEmpty(s1)) {
- if ((s1.charAt(0) != 34 || s1.charAt(s1.length() - 1) != 34) && (s1.charAt(0) != 123 || s1.charAt(s1.length() - 1) != 125)) {
- object = new TextComponent(s1);
- } else {
- try {
- object = GsonHelper.fromJson(DataConverterSignText.a, s1, Component.class, true);
- if (object == null) {
- object = new TextComponent("");
- }
- } catch (JsonParseException jsonparseexception) {
- ;
- }
-
- if (object == null) {
- try {
- object = Component.Serializer.fromJson(s1);
- } catch (JsonParseException jsonparseexception1) {
- ;
- }
- }
-
- if (object == null) {
- try {
- object = Component.Serializer.fromJsonLenient(s1);
- } catch (JsonParseException jsonparseexception2) {
- ;
- }
- }
-
- if (object == null) {
- object = new TextComponent(s1);
- }
- }
- } else {
- object = new TextComponent("");
- }
-
- nbttagcompound.putString(s, Component.Serializer.toJson(object));
- }
- }
-
- private static class DataInspectorPlayerVehicle implements DataInspector {
- @Override
- public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
- if (cmp.contains("RootVehicle", 10)) {
- CompoundTag nbttagcompound1 = cmp.getCompound("RootVehicle");
-
- if (nbttagcompound1.contains("Entity", 10)) {
- convertCompound(LegacyType.ENTITY, nbttagcompound1, "Entity", sourceVer, targetVer);
- }
- }
-
- return cmp;
- }
- }
-
- private static class DataInspectorLevelPlayer implements DataInspector {
- @Override
- public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
- if (cmp.contains("Player", 10)) {
- convertCompound(LegacyType.PLAYER, cmp, "Player", sourceVer, targetVer);
- }
-
- return cmp;
- }
- }
-
- private static class DataInspectorStructure implements DataInspector {
- @Override
- public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
- ListTag nbttaglist;
- int j;
- CompoundTag nbttagcompound1;
-
- if (cmp.contains("entities", 9)) {
- nbttaglist = cmp.getList("entities", 10);
-
- for (j = 0; j < nbttaglist.size(); ++j) {
- nbttagcompound1 = (CompoundTag) nbttaglist.get(j);
- if (nbttagcompound1.contains("nbt", 10)) {
- convertCompound(LegacyType.ENTITY, nbttagcompound1, "nbt", sourceVer, targetVer);
- }
- }
- }
-
- if (cmp.contains("blocks", 9)) {
- nbttaglist = cmp.getList("blocks", 10);
-
- for (j = 0; j < nbttaglist.size(); ++j) {
- nbttagcompound1 = (CompoundTag) nbttaglist.get(j);
- if (nbttagcompound1.contains("nbt", 10)) {
- convertCompound(LegacyType.BLOCK_ENTITY, nbttagcompound1, "nbt", sourceVer, targetVer);
- }
- }
- }
-
- return cmp;
- }
- }
-
- private static class DataInspectorChunks implements DataInspector {
- @Override
- public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
- if (cmp.contains("Level", 10)) {
- CompoundTag nbttagcompound1 = cmp.getCompound("Level");
- ListTag nbttaglist;
- int j;
-
- if (nbttagcompound1.contains("Entities", 9)) {
- nbttaglist = nbttagcompound1.getList("Entities", 10);
-
- for (j = 0; j < nbttaglist.size(); ++j) {
- nbttaglist.set(j, convert(LegacyType.ENTITY, (CompoundTag) nbttaglist.get(j), sourceVer, targetVer));
- }
- }
-
- if (nbttagcompound1.contains("TileEntities", 9)) {
- nbttaglist = nbttagcompound1.getList("TileEntities", 10);
-
- for (j = 0; j < nbttaglist.size(); ++j) {
- nbttaglist.set(j, convert(LegacyType.BLOCK_ENTITY, (CompoundTag) nbttaglist.get(j), sourceVer, targetVer));
- }
- }
- }
-
- return cmp;
- }
- }
-
- private static class DataInspectorEntityPassengers implements DataInspector {
- @Override
- public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
- if (cmp.contains("Passengers", 9)) {
- ListTag nbttaglist = cmp.getList("Passengers", 10);
-
- for (int j = 0; j < nbttaglist.size(); ++j) {
- nbttaglist.set(j, convert(LegacyType.ENTITY, nbttaglist.getCompound(j), sourceVer, targetVer));
- }
- }
-
- return cmp;
- }
- }
-
- private static class DataInspectorPlayer implements DataInspector {
- @Override
- public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
- convertItems(cmp, "Inventory", sourceVer, targetVer);
- convertItems(cmp, "EnderItems", sourceVer, targetVer);
- if (cmp.contains("ShoulderEntityLeft", 10)) {
- convertCompound(LegacyType.ENTITY, cmp, "ShoulderEntityLeft", sourceVer, targetVer);
- }
-
- if (cmp.contains("ShoulderEntityRight", 10)) {
- convertCompound(LegacyType.ENTITY, cmp, "ShoulderEntityRight", sourceVer, targetVer);
- }
-
- return cmp;
- }
- }
-
- private static class DataInspectorVillagers implements DataInspector {
- ResourceLocation entityVillager = getKey("EntityVillager");
-
- @Override
- public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
- if (entityVillager.equals(new ResourceLocation(cmp.getString("id"))) && cmp.contains("Offers", 10)) {
- CompoundTag nbttagcompound1 = cmp.getCompound("Offers");
-
- if (nbttagcompound1.contains("Recipes", 9)) {
- ListTag nbttaglist = nbttagcompound1.getList("Recipes", 10);
-
- for (int j = 0; j < nbttaglist.size(); ++j) {
- CompoundTag nbttagcompound2 = nbttaglist.getCompound(j);
-
- convertItem(nbttagcompound2, "buy", sourceVer, targetVer);
- convertItem(nbttagcompound2, "buyB", sourceVer, targetVer);
- convertItem(nbttagcompound2, "sell", sourceVer, targetVer);
- nbttaglist.set(j, nbttagcompound2);
- }
- }
- }
-
- return cmp;
- }
- }
-
- private static class DataInspectorMobSpawnerMinecart implements DataInspector {
- ResourceLocation entityMinecartMobSpawner = getKey("EntityMinecartMobSpawner");
- ResourceLocation tileEntityMobSpawner = getKey("TileEntityMobSpawner");
-
- @Override
- public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
- String s = cmp.getString("id");
- if (entityMinecartMobSpawner.equals(new ResourceLocation(s))) {
- cmp.putString("id", tileEntityMobSpawner.toString());
- convert(LegacyType.BLOCK_ENTITY, cmp, sourceVer, targetVer);
- cmp.putString("id", s);
- }
-
- return cmp;
- }
- }
-
- private static class DataInspectorMobSpawnerMobs implements DataInspector {
- ResourceLocation tileEntityMobSpawner = getKey("TileEntityMobSpawner");
-
- @Override
- public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
- if (tileEntityMobSpawner.equals(new ResourceLocation(cmp.getString("id")))) {
- if (cmp.contains("SpawnPotentials", 9)) {
- ListTag nbttaglist = cmp.getList("SpawnPotentials", 10);
-
- for (int j = 0; j < nbttaglist.size(); ++j) {
- CompoundTag nbttagcompound1 = nbttaglist.getCompound(j);
-
- convertCompound(LegacyType.ENTITY, nbttagcompound1, "Entity", sourceVer, targetVer);
- }
- }
-
- convertCompound(LegacyType.ENTITY, cmp, "SpawnData", sourceVer, targetVer);
- }
-
- return cmp;
- }
- }
-
- private static class DataInspectorCommandBlock implements DataInspector {
- ResourceLocation tileEntityCommand = getKey("TileEntityCommand");
-
- @Override
- public CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer) {
- if (tileEntityCommand.equals(new ResourceLocation(cmp.getString("id")))) {
- cmp.putString("id", "Control");
- convert(LegacyType.BLOCK_ENTITY, cmp, sourceVer, targetVer);
- cmp.putString("id", "MinecartCommandBlock");
- }
-
- return cmp;
- }
- }
-}
diff --git a/worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightFakePlayer.java b/worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightFakePlayer.java
deleted file mode 100644
index f3097a98bb..0000000000
--- a/worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightFakePlayer.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * WorldEdit, a Minecraft world manipulation toolkit
- * Copyright (C) sk89q
- * Copyright (C) WorldEdit team and contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.sk89q.worldedit.bukkit.adapter.impl.v1_18_R2;
-
-import com.mojang.authlib.GameProfile;
-import net.minecraft.network.chat.ChatType;
-import net.minecraft.network.chat.Component;
-import net.minecraft.network.protocol.game.ServerboundClientInformationPacket;
-import net.minecraft.server.level.ServerLevel;
-import net.minecraft.server.level.ServerPlayer;
-import net.minecraft.stats.Stat;
-import net.minecraft.world.MenuProvider;
-import net.minecraft.world.damagesource.DamageSource;
-import net.minecraft.world.entity.Entity;
-import net.minecraft.world.level.block.entity.SignBlockEntity;
-import net.minecraft.world.phys.Vec3;
-import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
-
-import java.util.OptionalInt;
-import java.util.UUID;
-
-class PaperweightFakePlayer extends ServerPlayer {
- private static final GameProfile FAKE_WORLDEDIT_PROFILE = new GameProfile(UUID.nameUUIDFromBytes("worldedit".getBytes()), "[WorldEdit]");
- private static final Vec3 ORIGIN = new Vec3(0.0D, 0.0D, 0.0D);
-
- PaperweightFakePlayer(ServerLevel world) {
- super(world.getServer(), world, FAKE_WORLDEDIT_PROFILE);
- }
-
- @Override
- public Vec3 position() {
- return ORIGIN;
- }
-
- @Override
- public void tick() {
- }
-
- @Override
- public void die(DamageSource damagesource) {
- }
-
- @Override
- public Entity changeDimension(ServerLevel worldserver, TeleportCause cause) {
- return this;
- }
-
- @Override
- public OptionalInt openMenu(MenuProvider factory) {
- return OptionalInt.empty();
- }
-
- @Override
- public void updateOptions(ServerboundClientInformationPacket packet) {
- }
-
- @Override
- public void displayClientMessage(Component message, boolean actionBar) {
- }
-
- @Override
- public void sendMessage(Component message, ChatType type, UUID sender) {
- }
-
- @Override
- public void awardStat(Stat> stat, int amount) {
- }
-
- @Override
- public void awardStat(Stat> stat) {
- }
-
- @Override
- public boolean isInvulnerableTo(DamageSource damageSource) {
- return true;
- }
-
- @Override
- public void openTextEdit(SignBlockEntity sign) {
- }
-}
diff --git a/worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightWorldNativeAccess.java b/worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightWorldNativeAccess.java
deleted file mode 100644
index 34775ae834..0000000000
--- a/worldedit-bukkit/adapters/adapter-1.18.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_18_R2/PaperweightWorldNativeAccess.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * WorldEdit, a Minecraft world manipulation toolkit
- * Copyright (C) sk89q
- * Copyright (C) WorldEdit team and contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.sk89q.worldedit.bukkit.adapter.impl.v1_18_R2;
-
-import com.sk89q.worldedit.bukkit.BukkitAdapter;
-import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
-import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
-import com.sk89q.worldedit.util.SideEffect;
-import com.sk89q.worldedit.util.SideEffectSet;
-import com.sk89q.worldedit.world.block.BlockState;
-import net.minecraft.core.BlockPos;
-import net.minecraft.nbt.CompoundTag;
-import net.minecraft.nbt.Tag;
-import net.minecraft.server.level.ChunkHolder;
-import net.minecraft.server.level.ServerLevel;
-import net.minecraft.world.level.block.Block;
-import net.minecraft.world.level.block.entity.BlockEntity;
-import net.minecraft.world.level.chunk.LevelChunk;
-import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
-import org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData;
-import org.bukkit.event.block.BlockPhysicsEvent;
-import org.enginehub.linbus.tree.LinCompoundTag;
-
-import java.lang.ref.WeakReference;
-import java.util.Objects;
-import javax.annotation.Nullable;
-
-public class PaperweightWorldNativeAccess implements WorldNativeAccess {
- private static final int UPDATE = 1;
- private static final int NOTIFY = 2;
-
- private final PaperweightAdapter adapter;
- private final WeakReference world;
- private SideEffectSet sideEffectSet;
-
- public PaperweightWorldNativeAccess(PaperweightAdapter adapter, WeakReference world) {
- this.adapter = adapter;
- this.world = world;
- }
-
- private ServerLevel getWorld() {
- return Objects.requireNonNull(world.get(), "The reference to the world was lost");
- }
-
- @Override
- public void setCurrentSideEffectSet(SideEffectSet sideEffectSet) {
- this.sideEffectSet = sideEffectSet;
- }
-
- @Override
- public LevelChunk getChunk(int x, int z) {
- return getWorld().getChunk(x, z);
- }
-
- @Override
- public net.minecraft.world.level.block.state.BlockState toNative(BlockState state) {
- int stateId = BlockStateIdAccess.getBlockStateId(state);
- return BlockStateIdAccess.isValidInternalId(stateId)
- ? Block.stateById(stateId)
- : ((CraftBlockData) BukkitAdapter.adapt(state)).getState();
- }
-
- @Override
- public net.minecraft.world.level.block.state.BlockState getBlockState(LevelChunk chunk, BlockPos position) {
- return chunk.getBlockState(position);
- }
-
- @Nullable
- @Override
- public net.minecraft.world.level.block.state.BlockState setBlockState(LevelChunk chunk, BlockPos position, net.minecraft.world.level.block.state.BlockState state) {
- return chunk.setBlockState(position, state, false, this.sideEffectSet.shouldApply(SideEffect.UPDATE));
- }
-
- @Override
- public net.minecraft.world.level.block.state.BlockState getValidBlockForPosition(net.minecraft.world.level.block.state.BlockState block, BlockPos position) {
- return Block.updateFromNeighbourShapes(block, getWorld(), position);
- }
-
- @Override
- public BlockPos getPosition(int x, int y, int z) {
- return new BlockPos(x, y, z);
- }
-
- @Override
- public void updateLightingForBlock(BlockPos position) {
- getWorld().getChunkSource().getLightEngine().checkBlock(position);
- }
-
- @Override
- public boolean updateTileEntity(BlockPos position, LinCompoundTag tag) {
- // We will assume that the tile entity was created for us
- BlockEntity tileEntity = getWorld().getBlockEntity(position);
- if (tileEntity == null) {
- return false;
- }
- Tag nativeTag = adapter.fromNative(tag);
- PaperweightAdapter.readTagIntoTileEntity((CompoundTag) nativeTag, tileEntity);
- return true;
- }
-
- @Override
- public void notifyBlockUpdate(LevelChunk chunk, BlockPos position, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) {
- if (chunk.getSections()[getWorld().getSectionIndex(position.getY())] != null) {
- getWorld().sendBlockUpdated(position, oldState, newState, UPDATE | NOTIFY);
- }
- }
-
- @Override
- public boolean isChunkTicking(LevelChunk chunk) {
- return chunk.getFullStatus().isOrAfter(ChunkHolder.FullChunkStatus.TICKING);
- }
-
- @Override
- public void markBlockChanged(LevelChunk chunk, BlockPos position) {
- if (chunk.getSections()[getWorld().getSectionIndex(position.getY())] != null) {
- getWorld().getChunkSource().blockChanged(position);
- }
- }
-
- @Override
- public void notifyNeighbors(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) {
- ServerLevel world = getWorld();
- if (sideEffectSet.shouldApply(SideEffect.EVENTS)) {
- world.updateNeighborsAt(pos, oldState.getBlock());
- } else {
- // When we don't want events, manually run the physics without them.
- Block block = oldState.getBlock();
- fireNeighborChanged(pos, world, block, pos.west());
- fireNeighborChanged(pos, world, block, pos.east());
- fireNeighborChanged(pos, world, block, pos.below());
- fireNeighborChanged(pos, world, block, pos.above());
- fireNeighborChanged(pos, world, block, pos.north());
- fireNeighborChanged(pos, world, block, pos.south());
- }
- if (newState.hasAnalogOutputSignal()) {
- world.updateNeighbourForOutputSignal(pos, newState.getBlock());
- }
- }
-
- @Override
- public void updateBlock(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) {
- ServerLevel world = getWorld();
- newState.onPlace(world, pos, oldState, false);
- }
-
- private void fireNeighborChanged(BlockPos pos, ServerLevel world, Block block, BlockPos neighborPos) {
- world.getBlockState(neighborPos).neighborChanged(world, neighborPos, block, pos, false);
- }
-
- @Override
- public void updateNeighbors(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState, int recursionLimit) {
- ServerLevel world = getWorld();
- // a == updateNeighbors
- // b == updateDiagonalNeighbors
- oldState.updateIndirectNeighbourShapes(world, pos, NOTIFY, recursionLimit);
- if (sideEffectSet.shouldApply(SideEffect.EVENTS)) {
- CraftWorld craftWorld = world.getWorld();
- BlockPhysicsEvent event = new BlockPhysicsEvent(craftWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), CraftBlockData.fromData(newState));
- world.getCraftServer().getPluginManager().callEvent(event);
- if (event.isCancelled()) {
- return;
- }
- }
- newState.updateNeighbourShapes(world, pos, NOTIFY, recursionLimit);
- newState.updateIndirectNeighbourShapes(world, pos, NOTIFY, recursionLimit);
- }
-
- @Override
- public void onBlockStateChange(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) {
- getWorld().onBlockStateChange(pos, oldState, newState);
- }
-}
diff --git a/worldedit-bukkit/adapters/adapter-1.19.4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1.19.4/build.gradle.kts
index df1bae5c83..c52e5712d4 100644
--- a/worldedit-bukkit/adapters/adapter-1.19.4/build.gradle.kts
+++ b/worldedit-bukkit/adapters/adapter-1.19.4/build.gradle.kts
@@ -1,6 +1,8 @@
import io.papermc.paperweight.userdev.PaperweightUserDependenciesExtension
-applyPaperweightAdapterConfiguration()
+plugins {
+ id("buildlogic.adapter")
+}
dependencies {
// https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
diff --git a/worldedit-bukkit/adapters/adapter-1.20.2/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1.20.2/build.gradle.kts
index 968c53ee22..c2ce87151e 100644
--- a/worldedit-bukkit/adapters/adapter-1.20.2/build.gradle.kts
+++ b/worldedit-bukkit/adapters/adapter-1.20.2/build.gradle.kts
@@ -1,6 +1,8 @@
import io.papermc.paperweight.userdev.PaperweightUserDependenciesExtension
-applyPaperweightAdapterConfiguration()
+plugins {
+ id("buildlogic.adapter")
+}
dependencies {
// https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
diff --git a/worldedit-bukkit/adapters/adapter-1.20.4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1.20.4/build.gradle.kts
index cdab328e73..8a6f722c97 100644
--- a/worldedit-bukkit/adapters/adapter-1.20.4/build.gradle.kts
+++ b/worldedit-bukkit/adapters/adapter-1.20.4/build.gradle.kts
@@ -1,6 +1,8 @@
import io.papermc.paperweight.userdev.PaperweightUserDependenciesExtension
-applyPaperweightAdapterConfiguration()
+plugins {
+ id("buildlogic.adapter")
+}
dependencies {
// https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
diff --git a/worldedit-bukkit/adapters/adapter-1.20.5/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1.20.5/build.gradle.kts
index 4cf500733a..130819e707 100644
--- a/worldedit-bukkit/adapters/adapter-1.20.5/build.gradle.kts
+++ b/worldedit-bukkit/adapters/adapter-1.20.5/build.gradle.kts
@@ -1,6 +1,8 @@
import io.papermc.paperweight.userdev.PaperweightUserDependenciesExtension
-applyPaperweightAdapterConfiguration()
+plugins {
+ id("buildlogic.adapter")
+}
dependencies {
// https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
diff --git a/worldedit-bukkit/adapters/adapter-1.20/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1.20/build.gradle.kts
index 52ada7865c..d1db9f9ac7 100644
--- a/worldedit-bukkit/adapters/adapter-1.20/build.gradle.kts
+++ b/worldedit-bukkit/adapters/adapter-1.20/build.gradle.kts
@@ -1,6 +1,8 @@
import io.papermc.paperweight.userdev.PaperweightUserDependenciesExtension
-applyPaperweightAdapterConfiguration()
+plugins {
+ id("buildlogic.adapter")
+}
dependencies {
// https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts
index b2ac1b362f..e5b6e41089 100644
--- a/worldedit-bukkit/build.gradle.kts
+++ b/worldedit-bukkit/build.gradle.kts
@@ -3,14 +3,19 @@ import io.papermc.paperweight.userdev.attribute.Obfuscation
plugins {
`java-library`
+ id("buildlogic.platform")
}
-applyPlatformAndCoreConfiguration()
-applyShadowConfiguration()
+platform {
+ kind = buildlogic.WorldEditKind.Plugin
+ includeClasspath = true
+}
repositories {
- maven { url = uri("https://hub.spigotmc.org/nexus/content/groups/public") }
- maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
+ maven {
+ name = "Spigot"
+ url = uri("https://hub.spigotmc.org/nexus/content/groups/public")
+ }
}
val localImplementation = configurations.create("localImplementation") {
@@ -79,8 +84,6 @@ tasks.named("processResources") {
}
}
-addJarManifest(WorldEditKind.Plugin, includeClasspath = true)
-
tasks.named("shadowJar") {
configurations.add(adapters)
dependencies {
diff --git a/worldedit-cli/build.gradle.kts b/worldedit-cli/build.gradle.kts
index d830726ba9..22f21f4714 100644
--- a/worldedit-cli/build.gradle.kts
+++ b/worldedit-cli/build.gradle.kts
@@ -2,17 +2,16 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
`java-library`
+ id("buildlogic.platform")
}
-applyPlatformAndCoreConfiguration()
-applyShadowConfiguration()
-addJarManifest(
- WorldEditKind.Standalone("com.sk89q.worldedit.cli.CLIWorldEdit"),
+platform {
+ kind = buildlogic.WorldEditKind.Standalone("com.sk89q.worldedit.cli.CLIWorldEdit")
extraAttributes = mapOf(
// We don't have any multi-release stuff, but Log4J does.
"Multi-Release" to "true",
- ),
-)
+ )
+}
dependencies {
"compileOnly"(project(":worldedit-libs:core:ap"))
diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts
index 4d03138672..6780e68712 100644
--- a/worldedit-core/build.gradle.kts
+++ b/worldedit-core/build.gradle.kts
@@ -4,10 +4,9 @@ import org.gradle.plugins.ide.idea.model.IdeaModel
plugins {
`java-library`
antlr
+ id("buildlogic.core-and-platform")
}
-applyPlatformAndCoreConfiguration()
-
repositories {
ivy {
url = uri("https://repo.enginehub.org/language-files/")
diff --git a/worldedit-core/doctools/build.gradle.kts b/worldedit-core/doctools/build.gradle.kts
index b921ebc72f..d12701190b 100644
--- a/worldedit-core/doctools/build.gradle.kts
+++ b/worldedit-core/doctools/build.gradle.kts
@@ -1,10 +1,9 @@
plugins {
kotlin("jvm") version "1.9.23"
application
+ id("buildlogic.common")
}
-applyCommonConfiguration()
-
application.mainClass.set("com.sk89q.worldedit.internal.util.DocumentationPrinter")
tasks.named("run") {
workingDir = rootProject.projectDir
diff --git a/worldedit-fabric/build.gradle.kts b/worldedit-fabric/build.gradle.kts
index 28c1dbc83a..273b6d5693 100644
--- a/worldedit-fabric/build.gradle.kts
+++ b/worldedit-fabric/build.gradle.kts
@@ -5,12 +5,20 @@ import net.fabricmc.loom.task.RemapJarTask
import net.fabricmc.loom.task.RunGameTask
plugins {
- id("fabric-loom")
+ alias(libs.plugins.fabric.loom)
`java-library`
+ id("buildlogic.platform")
}
-applyPlatformAndCoreConfiguration()
-applyShadowConfiguration()
+commonJava {
+ // Not easy to do, because it's in a bunch of separate configurations
+ banSlf4j = false
+}
+
+platform {
+ kind = buildlogic.WorldEditKind.Mod
+ includeClasspath = true
+}
val fabricApiConfiguration: Configuration = configurations.create("fabricApi")
@@ -24,12 +32,12 @@ tasks.withType().configureEach {
repositories {
maven {
- name = "Fabric"
- url = uri("https://maven.fabricmc.net/")
+ name = "EngineHub"
+ url = uri("https://maven.enginehub.org/repo/")
}
getByName("Mojang") {
content {
- includeGroupByRegex("com\\.mojang\\..*")
+ includeGroupAndSubgroups("com.mojang")
}
}
}
@@ -60,11 +68,6 @@ dependencies {
// No need for this at runtime
"modCompileOnly"(libs.fabric.permissions.api)
- // Hook these up manually, because Fabric doesn't seem to quite do it properly.
- "compileOnly"(libs.fabric.mixin)
- "annotationProcessor"(libs.fabric.mixin)
- "annotationProcessor"(libs.fabric.loom)
-
// Silence some warnings, since apparently this isn't on the compile classpath like it should be.
"compileOnly"(libs.errorprone.annotations)
}
@@ -88,8 +91,6 @@ tasks.named