Synchronize bundled data with WE (#2999)
This commit is contained in:
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal;
|
package com.sk89q.worldedit.internal;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class Constants {
|
public final class Constants {
|
||||||
@ -35,11 +33,11 @@ public final class Constants {
|
|||||||
public static final List<String> NO_COPY_ENTITY_NBT_FIELDS;
|
public static final List<String> NO_COPY_ENTITY_NBT_FIELDS;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
NO_COPY_ENTITY_NBT_FIELDS = Collections.unmodifiableList(Arrays.asList(
|
NO_COPY_ENTITY_NBT_FIELDS = List.of(
|
||||||
"UUIDLeast", "UUIDMost", "UUID", // Bukkit and Vanilla
|
"UUIDLeast", "UUIDMost", "UUID", // Bukkit and Vanilla
|
||||||
"WorldUUIDLeast", "WorldUUIDMost", // Bukkit and Vanilla
|
"WorldUUIDLeast", "WorldUUIDMost", // Bukkit and Vanilla
|
||||||
"PersistentIDMSB", "PersistentIDLSB" // Forge
|
"PersistentIDMSB", "PersistentIDLSB" // Forge
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,4 +84,14 @@ public final class Constants {
|
|||||||
*/
|
*/
|
||||||
public static final int DATA_VERSION_MC_1_20 = 3463;
|
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,7 +55,6 @@ public final class BundledItemData {
|
|||||||
|
|
||||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||||
private static BundledItemData INSTANCE;
|
private static BundledItemData INSTANCE;
|
||||||
private final ResourceLoader resourceLoader;
|
|
||||||
|
|
||||||
private final Map<String, ItemEntry> idMap = new HashMap<>();
|
private final Map<String, ItemEntry> idMap = new HashMap<>();
|
||||||
|
|
||||||
@ -63,12 +62,6 @@ public final class BundledItemData {
|
|||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*/
|
*/
|
||||||
private BundledItemData() {
|
private BundledItemData() {
|
||||||
this.resourceLoader = WorldEdit
|
|
||||||
.getInstance()
|
|
||||||
.getPlatformManager()
|
|
||||||
.queryCapability(Capability.CONFIGURATION)
|
|
||||||
.getResourceLoader();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loadFromResource();
|
loadFromResource();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
@ -85,28 +78,10 @@ public final class BundledItemData {
|
|||||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||||
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
|
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
|
||||||
Gson gson = gsonBuilder.create();
|
Gson gson = gsonBuilder.create();
|
||||||
URL url = null;
|
URL url = BundledRegistries.loadRegistry("items");
|
||||||
final int dataVersion = WorldEdit
|
LOGGER.debug("Using {} for bundled item data.", url);
|
||||||
.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");
|
|
||||||
}
|
|
||||||
String data = Resources.toString(url, Charset.defaultCharset());
|
String data = Resources.toString(url, Charset.defaultCharset());
|
||||||
List<ItemEntry> entries = gson.fromJson(data, new TypeToken<List<ItemEntry>>() {
|
List<ItemEntry> entries = gson.fromJson(data, new TypeToken<List<ItemEntry>>() {}.getType());
|
||||||
}.getType());
|
|
||||||
|
|
||||||
for (ItemEntry entry : entries) {
|
for (ItemEntry entry : entries) {
|
||||||
idMap.put(entry.id, entry);
|
idMap.put(entry.id, entry);
|
||||||
|
|||||||
@ -43,11 +43,9 @@ public class BundledRegistries implements Registries {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
TreeRangeMap<Integer, String> versionMap = TreeRangeMap.create();
|
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_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);
|
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
Reference in New Issue
Block a user