File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed
worldedit-core/src/main/java/com
fastasyncworldedit/core/registry/state
sk89q/worldedit/world/block Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -137,4 +137,9 @@ public int compareTo(@Nonnull PropertyKey o) {
137137 return Integer .compare (this .id , o .id );
138138 }
139139
140+ @ Override
141+ public String toString () {
142+ return "PropertyKey[" + getName () + "]" ;
143+ }
144+
140145}
Original file line number Diff line number Diff line change @@ -351,7 +351,7 @@ public <V> BlockState withProperties(final BlockState other) {
351351 BlockState newState = this ;
352352 for (Property <?> prop : ot .getProperties ()) {
353353 PropertyKey key = prop .getKey ();
354- if (blockType .hasProperty (key )) {
354+ if (blockType .hasPropertyOfType (key , prop . getClass () )) {
355355 newState = newState .with (key , other .getState (key ));
356356 }
357357 }
Original file line number Diff line number Diff line change @@ -247,6 +247,21 @@ public boolean hasProperty(PropertyKey key) {
247247 return this .settings .propertiesMapArr .length > ordinal && this .settings .propertiesMapArr [ordinal ] != null ;
248248 }
249249
250+ /**
251+ * {@return whether this block type has a property with given key of the given type}
252+ *
253+ * @param key the key identifying the property
254+ * @param propertyType the expected type of the property
255+ * @since TODO
256+ */
257+ public boolean hasPropertyOfType (PropertyKey key , Class <?> propertyType ) {
258+ int ordinal = key .getId ();
259+ Property <?> property ;
260+ return this .settings .propertiesMapArr .length > ordinal
261+ && (property = this .settings .propertiesMapArr [ordinal ]) != null
262+ && property .getClass () == propertyType ;
263+ }
264+
250265 public <V > Property <V > getProperty (PropertyKey key ) {
251266 try {
252267 return (Property <V >) this .settings .propertiesMapArr [key .getId ()];
You can’t perform that action at this time.
0 commit comments