From ee6af8ee768ea1d7a49bbb622925ea7a79ae351b Mon Sep 17 00:00:00 2001 From: kashike Date: Thu, 5 Jul 2018 16:16:52 -0700 Subject: [PATCH] state stuff --- .../com/sk89q/worldedit/blocks/BaseBlock.java | 15 ++--- .../extension/factory/DefaultBlockParser.java | 13 ++-- .../transform/BlockTransformExtent.java | 20 +++--- ...eStateValue.java => AbstractProperty.java} | 39 +++++------ ...nalState.java => DirectionalProperty.java} | 14 +++- .../state/{State.java => Property.java} | 4 +- .../worldedit/registry/state/SimpleState.java | 66 ------------------- .../state/value/DirectionalStateValue.java | 2 +- .../registry/state/value/StateValue.java | 49 -------------- .../worldedit/world/block/BlockState.java | 59 ++++++++--------- .../world/block/BlockStateHolder.java | 13 ++-- .../world/registry/BlockRegistry.java | 4 +- .../world/registry/BundledBlockData.java | 10 +-- .../world/registry/BundledBlockRegistry.java | 4 +- .../sk89q/worldedit/sponge/SpongeWorld.java | 5 +- 15 files changed, 99 insertions(+), 218 deletions(-) rename worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/{value/SimpleStateValue.java => AbstractProperty.java} (59%) rename worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/{DirectionalState.java => DirectionalProperty.java} (74%) rename worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/{State.java => Property.java} (92%) delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/SimpleState.java delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/value/StateValue.java diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java index 67324b934..10e0814d1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java @@ -22,14 +22,13 @@ package com.sk89q.worldedit.blocks; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; +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.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.world.registry.LegacyMapper; -import com.sk89q.worldedit.registry.state.State; -import com.sk89q.worldedit.registry.state.value.StateValue; import java.util.Map; import java.util.Objects; @@ -131,7 +130,7 @@ public class BaseBlock implements BlockStateHolder, TileEntityBlock { * @return The state map */ @Override - public Map getStates() { + public Map, Object> getStates() { return this.blockState.getStates(); } @@ -141,19 +140,19 @@ public class BaseBlock implements BlockStateHolder, TileEntityBlock { } @Override - public BaseBlock with(State state, StateValue value) { - return new BaseBlock(this.blockState.with(state, value), getNbtData()); + public BaseBlock with(Property property, V value) { + return new BaseBlock(this.blockState.with(property, value), getNbtData()); } /** * Gets the State for this Block. * - * @param state The state to get the value for + * @param property The state to get the value for * @return The state value */ @Override - public StateValue getState(State state) { - return this.blockState.getState(state); + public V getState(Property property) { + return this.blockState.getState(property); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java index 6ce02d530..cd73b31f3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java @@ -44,8 +44,7 @@ import com.sk89q.worldedit.internal.registry.InputParser; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.registry.BundledBlockData; -import com.sk89q.worldedit.registry.state.State; -import com.sk89q.worldedit.registry.state.value.StateValue; +import com.sk89q.worldedit.registry.state.Property; import java.util.HashMap; import java.util.Map; @@ -163,16 +162,16 @@ class DefaultBlockParser extends InputParser { throw new NoMatchException("Bad state format in " + parseableData); } - State stateKey = BundledBlockData.getInstance().findById(state.getBlockType().getId()).states.get(parts[0]); - if (stateKey == null) { + Property propertyKey = BundledBlockData.getInstance().findById(state.getBlockType().getId()).states.get(parts[0]); + if (propertyKey == null) { throw new NoMatchException("Unknown state " + parts[0] + " for block " + state.getBlockType().getName()); } - StateValue value = stateKey.getValueFor(parts[1]); + Object value = propertyKey.getValueFor(parts[1]); if (value == null) { throw new NoMatchException("Unknown value " + parts[1] + " for state " + parts[0]); } - state = state.with(stateKey, value); + state = state.with(propertyKey, value); } catch (NoMatchException e) { throw e; // Pass-through } catch (Exception e) { @@ -186,7 +185,7 @@ class DefaultBlockParser extends InputParser { private BlockStateHolder parseLogic(String input, ParserContext context) throws InputParseException { BlockType blockType; - Map blockStates = new HashMap<>(); + Map, Object> blockStates = new HashMap<>(); String[] blockAndExtraData = input.trim().split("\\|"); blockAndExtraData[0] = woolMapper(blockAndExtraData[0]); Matcher matcher = blockStatePattern.matcher(blockAndExtraData[0]); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java index 45aa2d97c..a04c25cfb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java @@ -32,8 +32,8 @@ import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.transform.Transform; -import com.sk89q.worldedit.registry.state.DirectionalState; -import com.sk89q.worldedit.registry.state.State; +import com.sk89q.worldedit.registry.state.DirectionalProperty; +import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.value.DirectionalStateValue; import java.util.Map; @@ -128,20 +128,20 @@ public class BlockTransformExtent extends AbstractDelegateExtent { checkNotNull(block); checkNotNull(transform); - Map states = WorldEdit.getInstance().getPlatformManager() + Map states = WorldEdit.getInstance().getPlatformManager() .queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getStates(block); if (states == null) { return changedBlock; } - for (State state : states.values()) { - if (state instanceof DirectionalState) { - DirectionalStateValue value = (DirectionalStateValue) block.getState(state); - if (value != null && value.getData() != null) { - DirectionalStateValue newValue = getNewStateValue((DirectionalState) state, transform, value.getDirection()); + for (Property property : states.values()) { + if (property instanceof DirectionalProperty) { + DirectionalStateValue value = (DirectionalStateValue) block.getState(property); + if (value != null) { + DirectionalStateValue newValue = getNewStateValue((DirectionalProperty) property, transform, value.getDirection()); if (newValue != null) { - changedBlock.with(state, newValue); + changedBlock.with(property, newValue); } } } @@ -159,7 +159,7 @@ public class BlockTransformExtent extends AbstractDelegateExtent { * @return a new state or null if none could be found */ @Nullable - private static DirectionalStateValue getNewStateValue(DirectionalState state, Transform transform, Vector oldDirection) { + private static DirectionalStateValue getNewStateValue(DirectionalProperty state, Transform transform, Vector oldDirection) { Vector newDirection = transform.apply(oldDirection).subtract(transform.apply(Vector.ZERO)).normalize(); DirectionalStateValue newValue = null; double closest = -2; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/value/SimpleStateValue.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/AbstractProperty.java similarity index 59% rename from worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/value/SimpleStateValue.java rename to worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/AbstractProperty.java index 6558a0e71..91589ea84 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/value/SimpleStateValue.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/AbstractProperty.java @@ -17,36 +17,31 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.registry.state.value; +package com.sk89q.worldedit.registry.state; -import java.util.Objects; +import static com.google.common.base.Preconditions.checkState; -public class SimpleStateValue implements StateValue { +public abstract class AbstractProperty implements Property { - private String data; + private String name; - @Override - public boolean isSet() { - return data != null; + public AbstractProperty() { + } + + public AbstractProperty(final String name) { + this.name = name; } @Override - public void set(String data) { - this.data = data; + public String getName() { + return this.name; } - @Override - public String getData() { - return this.data; - } - - @Override - public boolean equals(Object obj) { - return obj instanceof StateValue && Objects.equals(((StateValue) obj).getData(), getData()); - } - - @Override - public int hashCode() { - return this.data.hashCode(); + /** + * Internal method for name setting post-deserialise. Do not use. + */ + public void setName(final String name) { + checkState(this.name == null, "name already set"); + this.name = name; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/DirectionalState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/DirectionalProperty.java similarity index 74% rename from worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/DirectionalState.java rename to worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/DirectionalProperty.java index a4c83dd41..c165fdfff 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/DirectionalState.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/DirectionalProperty.java @@ -23,9 +23,17 @@ import com.sk89q.worldedit.registry.state.value.DirectionalStateValue; import java.util.List; -public class DirectionalState extends SimpleState { +import javax.annotation.Nullable; - public DirectionalState(List values) { - super(values); +public class DirectionalProperty extends AbstractProperty { + @Override + public List getValues() { + return null; + } + + @Nullable + @Override + public DirectionalStateValue getValueFor(final String string) { + return null; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/State.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/Property.java similarity index 92% rename from worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/State.java rename to worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/Property.java index ad6c819e6..069b279c5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/State.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/Property.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.registry.state; -import com.sk89q.worldedit.registry.state.value.SimpleStateValue; - import java.util.List; import javax.annotation.Nullable; @@ -31,7 +29,7 @@ import javax.annotation.Nullable; *

Example states include "variant" (indicating material or type) and * "facing" (indicating orientation).

*/ -public interface State { +public interface Property { /** * Returns the name of this state. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/SimpleState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/SimpleState.java deleted file mode 100644 index c31716d8f..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/SimpleState.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.registry.state; - -import com.sk89q.worldedit.registry.state.value.SimpleStateValue; - -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -import javax.annotation.Nullable; - -public class SimpleState implements State { - - private String name; - private List values; - - /** - * Creates a state with values - * - * @param values The values - */ - public SimpleState(List values) { - this.name = "Unknown"; - this.values = values; - } - - /** - * Internal method for name setting post-deserialise. Do not use. - */ - public void setName(String name) { - this.name = name; - } - - public String getName() { - return this.name; - } - - @Override - public List getValues() { - return Collections.unmodifiableList(values); - } - - @Nullable - @Override - public T getValueFor(String string) { - return values.stream().filter(value -> Objects.equals(value.getData(), string)).findFirst().orElse(null); - } -} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/value/DirectionalStateValue.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/value/DirectionalStateValue.java index 8923d7616..69d3e1ef4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/value/DirectionalStateValue.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/value/DirectionalStateValue.java @@ -21,7 +21,7 @@ package com.sk89q.worldedit.registry.state.value; import com.sk89q.worldedit.Vector; -public class DirectionalStateValue extends SimpleStateValue { +public class DirectionalStateValue { public Vector getDirection() { return new Vector(); // TODO diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/value/StateValue.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/value/StateValue.java deleted file mode 100644 index 3cc989f66..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/value/StateValue.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.registry.state.value; - -import javax.annotation.Nullable; - -/** - * Describes a possible value for a {@code State}. - */ -public interface StateValue { - - /** - * Return whether this state is set on the given block. - * - * @return true if this value is set - */ - boolean isSet(); - - /** - * Set the state to the given value. - */ - void set(String data); - - /** - * Returns the data associated with this value. - * - * @return The data, otherwise null - */ - @Nullable - String getData(); - -} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java index 2a0271e93..5297179f2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java @@ -23,8 +23,7 @@ import com.google.common.collect.ArrayTable; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Maps; import com.google.common.collect.Table; -import com.sk89q.worldedit.registry.state.State; -import com.sk89q.worldedit.registry.state.value.StateValue; +import com.sk89q.worldedit.registry.state.Property; import java.util.ArrayList; import java.util.Collections; @@ -39,11 +38,11 @@ import java.util.Map; public class BlockState implements BlockStateHolder { private final BlockType blockType; - private final Map values; + private final Map, Object> values; private final boolean fuzzy; // Neighbouring state table. - private Table states; + private Table, Object, BlockState> states; BlockState(BlockType blockType) { this.blockType = blockType; @@ -57,21 +56,21 @@ public class BlockState implements BlockStateHolder { * @param blockType The block type * @param values The block state values */ - public BlockState(BlockType blockType, Map values) { + public BlockState(BlockType blockType, Map, Object> values) { this.blockType = blockType; this.values = values; this.fuzzy = true; } - public void populate(Map, BlockState> stateMap) { - final Table states = HashBasedTable.create(); + public void populate(Map, Object>, BlockState> stateMap) { + final Table, Object, BlockState> states = HashBasedTable.create(); - for(final Map.Entry entry : this.values.entrySet()) { - final State state = entry.getKey(); + for(final Map.Entry, Object> entry : this.values.entrySet()) { + final Property property = entry.getKey(); - state.getValues().forEach(value -> { + property.getValues().forEach(value -> { if(value != entry.getValue()) { - states.put(state, (StateValue) value, stateMap.get(this.withValue(state, (StateValue) value))); + states.put(property, value, stateMap.get(this.withValue(property, value))); } }); } @@ -79,8 +78,8 @@ public class BlockState implements BlockStateHolder { this.states = states.isEmpty() ? states : ArrayTable.create(states); } - private Map withValue(final State property, final StateValue value) { - final Map values = Maps.newHashMap(this.values); + private Map, Object> withValue(final Property property, final V value) { + final Map, Object> values = Maps.newHashMap(this.values); values.put(property, value); return values; } @@ -91,22 +90,22 @@ public class BlockState implements BlockStateHolder { } @Override - public BlockState with(State state, StateValue value) { + public BlockState with(final Property property, final V value) { if (fuzzy) { - return setState(state, value); + return setState(property, value); } else { - BlockState result = states.get(state, value); + BlockState result = states.get(property, value); return result == null ? this : result; } } @Override - public StateValue getState(State state) { - return this.values.get(state); + public V getState(final Property property) { + return (V) this.values.get(property); } @Override - public Map getStates() { + public Map, Object> getStates() { return Collections.unmodifiableMap(this.values); } @@ -120,20 +119,20 @@ public class BlockState implements BlockStateHolder { return false; } - List differingStates = new ArrayList<>(); + List differingProperties = new ArrayList<>(); for (Object state : o.getStates().keySet()) { - if (getState((State) state) == null) { - differingStates.add((State) state); + if (getState((Property) state) == null) { + differingProperties.add((Property) state); } } - for (State state : getStates().keySet()) { - if (o.getState(state) == null) { - differingStates.add(state); + for (Property property : getStates().keySet()) { + if (o.getState(property) == null) { + differingProperties.add(property); } } - for (State state : differingStates) { - if (!getState(state).equals(o.getState(state))) { + for (Property property : differingProperties) { + if (!getState(property).equals(o.getState(property))) { return false; } } @@ -151,12 +150,12 @@ public class BlockState implements BlockStateHolder { * * Sets a value. DO NOT USE THIS. * - * @param state The state + * @param property The state * @param value The value * @return The blockstate, for chaining */ - private BlockState setState(State state, StateValue value) { - this.values.put(state, value); + private BlockState setState(final Property property, final V value) { + this.values.put(property, value); return this; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java index e1382ec04..10f171177 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java @@ -19,8 +19,7 @@ package com.sk89q.worldedit.world.block; -import com.sk89q.worldedit.registry.state.State; -import com.sk89q.worldedit.registry.state.value.StateValue; +import com.sk89q.worldedit.registry.state.Property; import java.util.Map; @@ -36,26 +35,26 @@ public interface BlockStateHolder { /** * Returns a BlockState with the given state and value applied. * - * @param state The state + * @param property The state * @param value The value * @return The modified state, or same if could not be applied */ - T with(State state, StateValue value); + T with(final Property property, final V value); /** * Gets the value at the given state * - * @param state The state + * @param property The state * @return The value */ - StateValue getState(State state); + V getState(Property property); /** * Gets an immutable collection of the states. * * @return The states */ - Map getStates(); + Map, Object> getStates(); /** * Checks if the type is the same, and if the matched states are the same. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java index 6320c2efc..02a50c1ac 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java @@ -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 getStates(BlockStateHolder block); + Map getStates(BlockStateHolder block); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java index a839bb179..e17ebc99a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java @@ -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 getStatesById(String id) { + public Map 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 aliases; - public Map states = new HashMap<>(); + public Map states = new HashMap<>(); private SimpleBlockMaterial material = new SimpleBlockMaterial(); void postDeserialization() { - for (Map.Entry state : states.entrySet()) { + for (Map.Entry state : states.entrySet()) { state.getValue().setName(state.getKey()); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockRegistry.java index 588df83c7..0d57ad7aa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockRegistry.java @@ -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 getStates(BlockStateHolder block) { + public Map getStates(BlockStateHolder block) { return BundledBlockData.getInstance().getStatesById(block.getBlockType().getId()); } diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java index 52730b518..0129d9d0e 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java @@ -27,6 +27,7 @@ import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseItemStack; +import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.entity.BaseEntity; @@ -35,8 +36,6 @@ import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.AbstractWorld; import com.sk89q.worldedit.world.biome.BaseBiome; -import com.sk89q.worldedit.registry.state.State; -import com.sk89q.worldedit.registry.state.value.StateValue; import org.spongepowered.api.Sponge; import org.spongepowered.api.block.BlockSnapshot; import org.spongepowered.api.block.BlockState; @@ -116,7 +115,7 @@ public abstract class SpongeWorld extends AbstractWorld { protected BlockState getBlockState(BlockStateHolder block) { if (block instanceof com.sk89q.worldedit.world.block.BlockState) { BlockState state = Sponge.getRegistry().getType(BlockType.class, block.getBlockType().getId()).orElse(BlockTypes.AIR).getDefaultState(); - for (Map.Entry entry : block.getStates().entrySet()) { + for (Map.Entry, Object> entry : block.getStates().entrySet()) { // TODO Convert across states } return state;