Merge remote-tracking branch 'refs/remotes/sk89q/master'

# Conflicts:

#	worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
#	worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java
#	worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java
This commit is contained in:
Jesse Boyd
2018-08-15 14:02:51 +10:00
24 changed files with 943 additions and 230 deletions

View File

@ -20,14 +20,14 @@
package com.sk89q.worldedit.world.registry;
import com.google.common.io.Resources;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.util.gson.VectorAdapter;
import java.io.IOException;
import java.lang.reflect.Type;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.HashMap;
@ -75,6 +75,18 @@ public class BundledBlockData {
private void loadFromResource() throws IOException {
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(Vector.class, new VectorAdapter());
gsonBuilder.registerTypeAdapter(int.class, new JsonDeserializer<Integer>() {
@Override
public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonPrimitive primitive = (JsonPrimitive) json;
if (primitive.isString()) {
String value = primitive.getAsString();
if (value.charAt(0) == '#') return Integer.parseInt(value.substring(1), 16);
return Integer.parseInt(value);
}
return primitive.getAsInt();
}
});
Gson gson = gsonBuilder.create();
URL url = BundledBlockData.class.getResource("blocks.json");
if (url == null) {

View File

@ -178,7 +178,11 @@ public class LegacyMapper {
private BlockState getBlock(int combinedId) {
if (combinedId < blockArr.length) {
return BlockState.get(blockArr[combinedId]);
try {
return BlockState.get(blockArr[combinedId]);
} catch (IndexOutOfBoundsException ignore) {
return null;
}
}
Integer extra = extraId4DataToStateId.get(combinedId);
if (extra == null) {

View File

@ -40,6 +40,15 @@ public class PassthroughBlockMaterial implements BlockMaterial {
}
}
@Override
public int getMapColor() {
if (blockMaterial == null) {
return 0;
} else {
return blockMaterial.getMapColor();
}
}
@Override
public boolean isFullCube() {
if (blockMaterial == null) {

View File

@ -43,6 +43,7 @@ class SimpleBlockMaterial implements BlockMaterial {
private boolean hasContainer;
private int lightOpacity;
private boolean isAir;
private int mapColor;
@Override
public boolean isAir() {
@ -53,6 +54,15 @@ class SimpleBlockMaterial implements BlockMaterial {
isAir = air;
}
@Override
public int getMapColor() {
return mapColor;
}
public void setMapColor(int mapColor) {
this.mapColor = mapColor;
}
@Override
public int getLightOpacity() {
return lightOpacity;