Skip to content

Commit 2158981

Browse files
authored
Synchronize bundled data with WE (#2999)
1 parent 308e909 commit 2158981

File tree

15 files changed

+21
-44
lines changed

15 files changed

+21
-44
lines changed

worldedit-core/src/main/java/com/sk89q/worldedit/internal/Constants.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
package com.sk89q.worldedit.internal;
2121

22-
import java.util.Arrays;
23-
import java.util.Collections;
2422
import java.util.List;
2523

2624
public final class Constants {
@@ -35,11 +33,11 @@ private Constants() {
3533
public static final List<String> NO_COPY_ENTITY_NBT_FIELDS;
3634

3735
static {
38-
NO_COPY_ENTITY_NBT_FIELDS = Collections.unmodifiableList(Arrays.asList(
36+
NO_COPY_ENTITY_NBT_FIELDS = List.of(
3937
"UUIDLeast", "UUIDMost", "UUID", // Bukkit and Vanilla
4038
"WorldUUIDLeast", "WorldUUIDMost", // Bukkit and Vanilla
4139
"PersistentIDMSB", "PersistentIDLSB" // Forge
42-
));
40+
);
4341
}
4442

4543
/**
@@ -86,4 +84,14 @@ private Constants() {
8684
*/
8785
public static final int DATA_VERSION_MC_1_20 = 3463;
8886

87+
/**
88+
* The DataVersion for Minecraft 1.21
89+
*/
90+
public static final int DATA_VERSION_MC_1_21 = 3953;
91+
92+
/**
93+
* The DataVersion for Minecraft 1.21.3
94+
*/
95+
public static final int DATA_VERSION_MC_1_21_3 = 4082;
96+
8997
}

worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,13 @@ public final class BundledItemData {
5555

5656
private static final Logger LOGGER = LogManagerCompat.getLogger();
5757
private static BundledItemData INSTANCE;
58-
private final ResourceLoader resourceLoader;
5958

6059
private final Map<String, ItemEntry> idMap = new HashMap<>();
6160

6261
/**
6362
* Create a new instance.
6463
*/
6564
private BundledItemData() {
66-
this.resourceLoader = WorldEdit
67-
.getInstance()
68-
.getPlatformManager()
69-
.queryCapability(Capability.CONFIGURATION)
70-
.getResourceLoader();
71-
7265
try {
7366
loadFromResource();
7467
} catch (Throwable e) {
@@ -85,28 +78,10 @@ private void loadFromResource() throws IOException {
8578
GsonBuilder gsonBuilder = new GsonBuilder();
8679
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
8780
Gson gson = gsonBuilder.create();
88-
URL url = null;
89-
final int dataVersion = WorldEdit
90-
.getInstance()
91-
.getPlatformManager()
92-
.queryCapability(Capability.WORLD_EDITING)
93-
.getDataVersion();
94-
if (dataVersion >= Constants.DATA_VERSION_MC_1_17) {
95-
url = resourceLoader.getResource(BundledBlockData.class, "items.117.json");
96-
} else if (dataVersion >= Constants.DATA_VERSION_MC_1_16) {
97-
url = resourceLoader.getResource(BundledBlockData.class, "items.116.json");
98-
} else if (dataVersion >= Constants.DATA_VERSION_MC_1_15) {
99-
url = resourceLoader.getResource(BundledBlockData.class, "items.115.json");
100-
}
101-
if (url == null) {
102-
url = resourceLoader.getResource(BundledBlockData.class, "items.json");
103-
}
104-
if (url == null) {
105-
throw new IOException("Could not find items.json");
106-
}
81+
URL url = BundledRegistries.loadRegistry("items");
82+
LOGGER.debug("Using {} for bundled item data.", url);
10783
String data = Resources.toString(url, Charset.defaultCharset());
108-
List<ItemEntry> entries = gson.fromJson(data, new TypeToken<List<ItemEntry>>() {
109-
}.getType());
84+
List<ItemEntry> entries = gson.fromJson(data, new TypeToken<List<ItemEntry>>() {}.getType());
11085

11186
for (ItemEntry entry : entries) {
11287
idMap.put(entry.id, entry);

worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledRegistries.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@ public class BundledRegistries implements Registries {
4343

4444
static {
4545
TreeRangeMap<Integer, String> versionMap = TreeRangeMap.create();
46-
versionMap.put(Range.atLeast(Constants.DATA_VERSION_MC_1_16), "116");
47-
versionMap.put(Range.atLeast(Constants.DATA_VERSION_MC_1_17), "117");
48-
// 1.18 did have one item change, but we didn't get it. It's fine.
49-
versionMap.put(Range.atLeast(Constants.DATA_VERSION_MC_1_19), "119");
5046
versionMap.put(Range.atLeast(Constants.DATA_VERSION_MC_1_20), "120");
47+
versionMap.put(Range.atLeast(Constants.DATA_VERSION_MC_1_21), "121");
48+
versionMap.put(Range.atLeast(Constants.DATA_VERSION_MC_1_21_3), "1213");
5149
VERSION_MAP = ImmutableRangeMap.copyOf(versionMap);
5250
}
5351

worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.115.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.116.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.117.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.119.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.121.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.1213.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/items.115.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)