mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 10:56:42 +00:00
Upstream
This commit is contained in:
@ -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");
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user