Skip to content

Commit af2acad

Browse files
committed
implement 1.21.9
1 parent 49d6a9d commit af2acad

30 files changed

+8848
-17
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ allprojects {
8282
}
8383

8484
applyCommonConfiguration()
85-
val supportedVersions = listOf("1.20.4", "1.20.5", "1.20.6", "1.21", "1.21.1", "1.21.4", "1.21.5", "1.21.8")
85+
val supportedVersions = listOf("1.20.4", "1.20.5", "1.20.6", "1.21", "1.21.1", "1.21.4", "1.21.5", "1.21.8", "1.21.9")
8686

8787
tasks {
8888
supportedVersions.forEach {

buildSrc/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ dependencies {
2424
implementation(gradleApi())
2525
implementation("org.ajoberstar.grgit:grgit-gradle:5.3.3")
2626
implementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.9")
27-
implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:2.0.0-SNAPSHOT")
27+
// TODO: update to 2.0.0-SNAPSHOT when using Gradle 9
28+
implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:2.0.0-beta.18")
2829
constraints {
2930
val asmVersion = "[9.7,)"
3031
implementation("org.ow2.asm:asm:$asmVersion") {

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ rootProject.name = "FastAsyncWorldEdit"
22

33
include("worldedit-libs")
44

5-
listOf("1_20_2", "1_20_4", "1_20_5", "1_21", "1_21_4", "1_21_5", "1_21_6").forEach {
5+
listOf("1_20_2", "1_20_4", "1_20_5", "1_21", "1_21_4", "1_21_5", "1_21_6", "1_21_9").forEach {
66
include("worldedit-bukkit:adapters:adapter-$it")
77
}
88

worldedit-bukkit/adapters/adapter-1_21_6/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_6/PaperweightAdapter.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,6 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
204204

205205
private static final RandomSource random = RandomSource.create();
206206

207-
private static final String WRONG_VERSION =
208-
"""
209-
This version of FastAsyncWorldEdit has not been tested with the current Minecraft version.
210-
While it may work, there might be unexpected issues.
211-
It is recommended to use a version of FastAsyncWorldEdit that supports your Minecraft version.
212-
""".stripIndent();
213207

214208
// ------------------------------------------------------------------------
215209
// Code that may break between versions of Minecraft
@@ -221,7 +215,7 @@ public PaperweightAdapter() throws NoSuchFieldException, NoSuchMethodException {
221215

222216
int dataVersion = SharedConstants.getCurrentVersion().dataVersion().version();
223217
if (dataVersion != Constants.DATA_VERSION_MC_1_21_6 && dataVersion != Constants.DATA_VERSION_MC_1_21_7 && dataVersion != Constants.DATA_VERSION_MC_1_21_8) {
224-
logger.warning(WRONG_VERSION);
218+
throw new UnsupportedClassVersionError("Not 1.21.(6/7/8)!");
225219
}
226220

227221
serverWorldsField = CraftServer.class.getDeclaredField("worlds");

worldedit-bukkit/adapters/adapter-1_21_6/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_21_6/PaperweightFaweWorldNativeAccess.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ public synchronized net.minecraft.world.level.block.state.BlockState setBlockSta
100100
) {
101101
int currentTick = MinecraftServer.currentTick;
102102
if (Fawe.isMainThread()) {
103-
return levelChunk.setBlockState(blockPos, blockState,
103+
return levelChunk.setBlockState(
104+
blockPos, blockState,
104105
this.sideEffectSet.shouldApply(SideEffect.UPDATE) ? 0 : 512
105106
);
106107
}
@@ -188,7 +189,13 @@ public void notifyNeighbors(
188189
// Un-nest neighbour updating
189190
for (Direction direction : NEIGHBOUR_ORDER) {
190191
BlockPos shifted = blockPos.relative(direction);
191-
level.getBlockState(shifted).handleNeighborChanged(level, shifted, oldState.getBlock(), ExperimentalRedstoneUtils.initialOrientation(level, null, null), false);
192+
level.getBlockState(shifted).handleNeighborChanged(
193+
level,
194+
shifted,
195+
oldState.getBlock(),
196+
ExperimentalRedstoneUtils.initialOrientation(level, null, null),
197+
false
198+
);
192199
}
193200
}
194201
if (newState.hasAnalogOutputSignal()) {
@@ -225,7 +232,11 @@ public void updateNeighbors(
225232
}
226233

227234
@Override
228-
public void updateBlock(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) {
235+
public void updateBlock(
236+
BlockPos pos,
237+
net.minecraft.world.level.block.state.BlockState oldState,
238+
net.minecraft.world.level.block.state.BlockState newState
239+
) {
229240
Level world = getLevel();
230241
newState.onPlace(world, pos, oldState, false);
231242
}
@@ -252,7 +263,8 @@ private synchronized void flushAsync(final boolean sendChunks) {
252263
RunnableVal<Object> runnableVal = new RunnableVal<>() {
253264
@Override
254265
public void run(Object value) {
255-
changes.forEach(cc -> cc.levelChunk.setBlockState(cc.blockPos, cc.blockState,
266+
changes.forEach(cc -> cc.levelChunk.setBlockState(
267+
cc.blockPos, cc.blockState,
256268
sideEffectSet.shouldApply(SideEffect.UPDATE) ? 0 : 512
257269
));
258270
if (!sendChunks) {
@@ -271,7 +283,8 @@ public synchronized void flush() {
271283
RunnableVal<Object> runnableVal = new RunnableVal<>() {
272284
@Override
273285
public void run(Object value) {
274-
cachedChanges.forEach(cc -> cc.levelChunk.setBlockState(cc.blockPos, cc.blockState,
286+
cachedChanges.forEach(cc -> cc.levelChunk.setBlockState(
287+
cc.blockPos, cc.blockState,
275288
sideEffectSet.shouldApply(SideEffect.UPDATE) ? 0 : 512
276289
));
277290
for (IntPair chunk : cachedChunksToSend) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import io.papermc.paperweight.userdev.PaperweightUserDependenciesExtension
2+
3+
plugins {
4+
java
5+
}
6+
7+
applyPaperweightAdapterConfiguration()
8+
9+
repositories {
10+
gradlePluginPortal()
11+
}
12+
13+
dependencies {
14+
// https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
15+
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.21.9-R0.1-20251002.164528-7")
16+
compileOnly(libs.paperlib)
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* WorldEdit, a Minecraft world manipulation toolkit
3+
* Copyright (C) sk89q <http://www.sk89q.com>
4+
* Copyright (C) WorldEdit team and contributors
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
package com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_21_9;
21+
22+
import com.google.gson.Gson;
23+
import com.google.gson.GsonBuilder;
24+
import com.google.gson.JsonElement;
25+
import com.google.gson.JsonParseException;
26+
import com.google.gson.JsonParser;
27+
import com.google.gson.Strictness;
28+
import com.google.gson.stream.JsonReader;
29+
import com.mojang.serialization.JsonOps;
30+
import net.minecraft.core.HolderLookup;
31+
import net.minecraft.network.chat.Component;
32+
import net.minecraft.network.chat.ComponentSerialization;
33+
import net.minecraft.network.chat.MutableComponent;
34+
35+
import javax.annotation.Nullable;
36+
import java.io.StringReader;
37+
38+
public class ComponentConverter {
39+
40+
public static class Serializer {
41+
private static final Gson GSON = (new GsonBuilder()).disableHtmlEscaping().create();
42+
43+
private Serializer() {
44+
}
45+
46+
static MutableComponent deserialize(JsonElement json, HolderLookup.Provider registries) {
47+
return (MutableComponent) ComponentSerialization.CODEC.parse(registries.createSerializationContext(JsonOps.INSTANCE), json).getOrThrow(JsonParseException::new);
48+
}
49+
50+
static JsonElement serialize(Component text, HolderLookup.Provider registries) {
51+
return ComponentSerialization.CODEC.encodeStart(registries.createSerializationContext(JsonOps.INSTANCE), text).getOrThrow(JsonParseException::new);
52+
}
53+
54+
public static String toJson(Component text, HolderLookup.Provider registries) {
55+
return GSON.toJson(serialize(text, registries));
56+
}
57+
58+
@Nullable
59+
public static MutableComponent fromJson(String json, HolderLookup.Provider registries) {
60+
JsonElement jsonelement = JsonParser.parseString(json);
61+
return jsonelement == null ? null : deserialize(jsonelement, registries);
62+
}
63+
64+
@Nullable
65+
public static MutableComponent fromJson(@Nullable JsonElement json, HolderLookup.Provider registries) {
66+
return json == null ? null : deserialize(json, registries);
67+
}
68+
69+
@Nullable
70+
public static MutableComponent fromJsonLenient(String json, HolderLookup.Provider registries) {
71+
JsonReader jsonreader = new JsonReader(new StringReader(json));
72+
jsonreader.setStrictness(Strictness.LENIENT);
73+
JsonElement jsonelement = JsonParser.parseReader(jsonreader);
74+
return jsonelement == null ? null : deserialize(jsonelement, registries);
75+
}
76+
}
77+
}

0 commit comments

Comments
 (0)