Initial attempt at binding state IDs

This commit is contained in:
Kenzie Togami
2019-02-20 23:47:33 -08:00
committed by Matthew Miller
parent e69ba31d6b
commit a3a175ab8c
11 changed files with 101 additions and 6 deletions

View File

@ -20,9 +20,11 @@
package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import java.util.Map;
import java.util.OptionalInt;
import javax.annotation.Nullable;
@ -57,4 +59,12 @@ public interface BlockRegistry {
*/
Map<String, ? extends Property<?>> getProperties(BlockType blockType);
/**
* Retrieve the internal ID for a given state, if possible.
*
* @param state The block state
* @return the internal ID of the state
*/
OptionalInt getInternalBlockStateId(BlockState state);
}

View File

@ -20,10 +20,12 @@
package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import java.util.Collections;
import java.util.Map;
import java.util.OptionalInt;
import javax.annotation.Nullable;
@ -52,4 +54,9 @@ public class BundledBlockRegistry implements BlockRegistry {
return Collections.emptyMap(); // Oof
}
@Override
public OptionalInt getInternalBlockStateId(BlockState state) {
return OptionalInt.empty();
}
}

View File

@ -75,7 +75,7 @@ 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 = ResourceLoader.getResource(BundledItemData.class,"items.json");F
if (url == null) {
throw new IOException("Could not find items.json");
}