mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Add 1.14 blocks, items, entities, and tags. (#490)
Should remain backwards compatible with 1.13. Removed blocks/items will be forwarded to the "replacement" block/item. (e.g. BlockTypes.SIGN will find OAK_SIGN on 1.14.)
This commit is contained in:
@ -23,6 +23,8 @@ import com.google.common.io.Resources;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.gson.VectorAdapter;
|
||||
import com.sk89q.worldedit.util.io.ResourceLoader;
|
||||
@ -48,7 +50,7 @@ import java.util.Map;
|
||||
* reading fails (which occurs when this class is first instantiated), then
|
||||
* the methods will return {@code null}s for all blocks.</p>
|
||||
*/
|
||||
public class BundledBlockData {
|
||||
public final class BundledBlockData {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(BundledBlockData.class);
|
||||
private static BundledBlockData INSTANCE;
|
||||
@ -75,10 +77,18 @@ public class BundledBlockData {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
|
||||
Gson gson = gsonBuilder.create();
|
||||
URL url = ResourceLoader.getResource(BundledBlockData.class, "blocks.json");
|
||||
URL url = null;
|
||||
final int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion();
|
||||
if (dataVersion > 1900) { // > MC 1.13
|
||||
url = ResourceLoader.getResource(BundledBlockData.class, "blocks.114.json");
|
||||
}
|
||||
if (url == null) {
|
||||
url = ResourceLoader.getResource(BundledBlockData.class, "blocks.json");
|
||||
}
|
||||
if (url == null) {
|
||||
throw new IOException("Could not find blocks.json");
|
||||
}
|
||||
log.debug("Using {} for bundled block data.", url);
|
||||
String data = Resources.toString(url, Charset.defaultCharset());
|
||||
List<BlockEntry> entries = gson.fromJson(data, new TypeToken<List<BlockEntry>>() {}.getType());
|
||||
|
||||
|
@ -23,6 +23,8 @@ import com.google.common.io.Resources;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.gson.VectorAdapter;
|
||||
import com.sk89q.worldedit.util.io.ResourceLoader;
|
||||
@ -48,7 +50,7 @@ import java.util.Map;
|
||||
* reading fails (which occurs when this class is first instantiated), then
|
||||
* the methods will return {@code null}s for all items.</p>
|
||||
*/
|
||||
public class BundledItemData {
|
||||
public final class BundledItemData {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(BundledItemData.class);
|
||||
private static BundledItemData INSTANCE;
|
||||
@ -75,10 +77,18 @@ public class BundledItemData {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
|
||||
Gson gson = gsonBuilder.create();
|
||||
URL url = ResourceLoader.getResource(BundledItemData.class,"items.json");
|
||||
URL url = null;
|
||||
final int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion();
|
||||
if (dataVersion > 1900) { // > MC 1.13
|
||||
url = ResourceLoader.getResource(BundledBlockData.class, "items.114.json");
|
||||
}
|
||||
if (url == null) {
|
||||
url = ResourceLoader.getResource(BundledBlockData.class, "items.json");
|
||||
}
|
||||
if (url == null) {
|
||||
throw new IOException("Could not find items.json");
|
||||
}
|
||||
log.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());
|
||||
|
||||
|
Reference in New Issue
Block a user