Synchronize bundled data with WE (#2999)

This commit is contained in:
Hannes Greule
2024-11-23 18:55:04 +01:00
committed by GitHub
parent 308e909dea
commit 215898158f
15 changed files with 21 additions and 44 deletions

View File

@ -19,8 +19,6 @@
package com.sk89q.worldedit.internal;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public final class Constants {
@ -35,11 +33,11 @@ public final class Constants {
public static final List<String> NO_COPY_ENTITY_NBT_FIELDS;
static {
NO_COPY_ENTITY_NBT_FIELDS = Collections.unmodifiableList(Arrays.asList(
NO_COPY_ENTITY_NBT_FIELDS = List.of(
"UUIDLeast", "UUIDMost", "UUID", // Bukkit and Vanilla
"WorldUUIDLeast", "WorldUUIDMost", // Bukkit and Vanilla
"PersistentIDMSB", "PersistentIDLSB" // Forge
));
);
}
/**
@ -86,4 +84,14 @@ public final class Constants {
*/
public static final int DATA_VERSION_MC_1_20 = 3463;
/**
* The DataVersion for Minecraft 1.21
*/
public static final int DATA_VERSION_MC_1_21 = 3953;
/**
* The DataVersion for Minecraft 1.21.3
*/
public static final int DATA_VERSION_MC_1_21_3 = 4082;
}

View File

@ -55,7 +55,6 @@ public final class BundledItemData {
private static final Logger LOGGER = LogManagerCompat.getLogger();
private static BundledItemData INSTANCE;
private final ResourceLoader resourceLoader;
private final Map<String, ItemEntry> idMap = new HashMap<>();
@ -63,12 +62,6 @@ public final class BundledItemData {
* Create a new instance.
*/
private BundledItemData() {
this.resourceLoader = WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.CONFIGURATION)
.getResourceLoader();
try {
loadFromResource();
} catch (Throwable e) {
@ -85,28 +78,10 @@ public final class BundledItemData {
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
Gson gson = gsonBuilder.create();
URL url = null;
final int dataVersion = WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.WORLD_EDITING)
.getDataVersion();
if (dataVersion >= Constants.DATA_VERSION_MC_1_17) {
url = resourceLoader.getResource(BundledBlockData.class, "items.117.json");
} else if (dataVersion >= Constants.DATA_VERSION_MC_1_16) {
url = resourceLoader.getResource(BundledBlockData.class, "items.116.json");
} else if (dataVersion >= Constants.DATA_VERSION_MC_1_15) {
url = resourceLoader.getResource(BundledBlockData.class, "items.115.json");
}
if (url == null) {
url = resourceLoader.getResource(BundledBlockData.class, "items.json");
}
if (url == null) {
throw new IOException("Could not find items.json");
}
URL url = BundledRegistries.loadRegistry("items");
LOGGER.debug("Using {} for bundled item data.", url);
String data = Resources.toString(url, Charset.defaultCharset());
List<ItemEntry> entries = gson.fromJson(data, new TypeToken<List<ItemEntry>>() {
}.getType());
List<ItemEntry> entries = gson.fromJson(data, new TypeToken<List<ItemEntry>>() {}.getType());
for (ItemEntry entry : entries) {
idMap.put(entry.id, entry);

View File

@ -43,11 +43,9 @@ public class BundledRegistries implements Registries {
static {
TreeRangeMap<Integer, String> versionMap = TreeRangeMap.create();
versionMap.put(Range.atLeast(Constants.DATA_VERSION_MC_1_16), "116");
versionMap.put(Range.atLeast(Constants.DATA_VERSION_MC_1_17), "117");
// 1.18 did have one item change, but we didn't get it. It's fine.
versionMap.put(Range.atLeast(Constants.DATA_VERSION_MC_1_19), "119");
versionMap.put(Range.atLeast(Constants.DATA_VERSION_MC_1_20), "120");
versionMap.put(Range.atLeast(Constants.DATA_VERSION_MC_1_21), "121");
versionMap.put(Range.atLeast(Constants.DATA_VERSION_MC_1_21_3), "1213");
VERSION_MAP = ImmutableRangeMap.copyOf(versionMap);
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long