This commit is contained in:
MattBDev
2019-06-25 13:07:47 -04:00
parent a1c15e1c39
commit a69b239848
143 changed files with 1042 additions and 2405 deletions

View File

@ -73,17 +73,14 @@ public class BundledBlockData {
private void loadFromResource() throws IOException {
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(Vector3.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();
gsonBuilder.registerTypeAdapter(int.class, (JsonDeserializer<Integer>) (json, typeOfT, context) -> {
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");

View File

@ -22,8 +22,6 @@ package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.world.item.ItemType;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
/**
* A item registry that uses {@link BundledItemRegistry} to serve information
@ -46,9 +44,4 @@ public class BundledItemRegistry implements ItemRegistry {
}
return null;
}
@Override
public Collection<String> registerItems() {
return Collections.emptyList();
}
}

View File

@ -22,18 +22,9 @@ package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.world.item.ItemType;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
public interface ItemRegistry {
/**
* Register all items
*/
default Collection<String> registerItems() {
return Collections.emptyList();
}
/**
* Gets the name for the given item.
*

View File

@ -94,7 +94,6 @@ public class LegacyMapper {
for (Map.Entry<String, String> blockEntry : dataFile.blocks.entrySet()) {
try {
BlockStateHolder blockState = BlockState.get(null, blockEntry.getValue());
// BlockState blockState = WorldEdit.getInstance().getBlockFactory().parseFromInput(blockEntry.getValue(), parserContext).toImmutableState();
BlockType type = blockState.getBlockType();
if (type.hasProperty(PropertyKey.WATERLOGGED)) {
blockState = blockState.with(PropertyKey.WATERLOGGED, false);
@ -160,7 +159,11 @@ public class LegacyMapper {
@Nullable
public int[] getLegacyFromItem(ItemType itemType) {
Integer combinedId = getLegacyCombined(itemType);
return combinedId == null ? null : new int[] { combinedId >> 4, combinedId & 0xF };
if (combinedId == null) {
return null;
} else {
return new int[]{combinedId >> 4, combinedId & 0xF};
}
}
@Nullable