state stuff

This commit is contained in:
kashike
2018-07-05 16:16:52 -07:00
committed by Matthew Miller
parent 40a665a509
commit ee6af8ee76
15 changed files with 99 additions and 218 deletions

View File

@ -22,7 +22,7 @@ package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.registry.state.State;
import com.sk89q.worldedit.registry.state.Property;
import java.util.Map;
@ -58,6 +58,6 @@ public interface BlockRegistry {
* @return a map of states where the key is the state's ID
*/
@Nullable
Map<String, ? extends State> getStates(BlockStateHolder block);
Map<String, ? extends Property> getStates(BlockStateHolder block);
}

View File

@ -25,9 +25,9 @@ import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.gson.VectorAdapter;
import com.sk89q.worldedit.registry.state.SimpleState;
import com.sk89q.worldedit.registry.state.State;
import com.sk89q.worldedit.registry.state.AbstractProperty;
import javax.annotation.Nullable;
import java.io.IOException;
@ -128,7 +128,7 @@ public class BundledBlockData {
* @return the block's states, or null if no information is available
*/
@Nullable
public Map<String, ? extends State> getStatesById(String id) {
public Map<String, ? extends Property> getStatesById(String id) {
BlockEntry entry = findById(id);
if (entry != null) {
return entry.states;
@ -151,11 +151,11 @@ public class BundledBlockData {
private String unlocalizedName;
public String localizedName;
private List<String> aliases;
public Map<String, SimpleState> states = new HashMap<>();
public Map<String, AbstractProperty> states = new HashMap<>();
private SimpleBlockMaterial material = new SimpleBlockMaterial();
void postDeserialization() {
for (Map.Entry<String, SimpleState> state : states.entrySet()) {
for (Map.Entry<String, AbstractProperty> state : states.entrySet()) {
state.getValue().setName(state.getKey());
}
}

View File

@ -20,10 +20,10 @@
package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.registry.state.State;
import java.util.Map;
@ -49,7 +49,7 @@ public class BundledBlockRegistry implements BlockRegistry {
@Nullable
@Override
public Map<String, ? extends State> getStates(BlockStateHolder block) {
public Map<String, ? extends Property> getStates(BlockStateHolder block) {
return BundledBlockData.getInstance().getStatesById(block.getBlockType().getId());
}