Allow ^ mask to be used between blocks that may have different properties, only keeping the shared properties

Fixes #1092
This commit is contained in:
dordsor21 2021-06-10 12:46:19 +01:00
parent dd217fcb70
commit 71130025e8
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
3 changed files with 6 additions and 8 deletions

View File

@ -23,6 +23,7 @@ import com.google.common.collect.Maps;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
@ -47,8 +48,10 @@ public class StateApplyingPattern extends AbstractExtentPattern {
BlockState block = getExtent().getBlock(position);
for (Entry<Property<Object>, Object> entry : cache
.computeIfAbsent(block.getBlockType(), (b -> resolveProperties(states, b))).entrySet()) {
if (block.getBlockType().hasProperty(entry.getKey().getKey())) {
block = block.with(entry.getKey(), entry.getValue());
}
}
return block.toBaseBlock();
}
}

View File

@ -41,12 +41,7 @@ public class TypeApplyingPattern extends AbstractExtentPattern {
@Override
public BaseBlock apply(BlockVector3 position) {
BlockState oldBlock = getExtent().getBlock(position);
BlockState newBlock = blockState;
for (Entry<Property<?>, Object> entry : oldBlock.getStates().entrySet()) {
@SuppressWarnings("unchecked")
Property<Object> prop = (Property<Object>) entry.getKey();
newBlock = newBlock.with(prop, entry.getValue());
}
BlockState newBlock = blockState.withProperties(oldBlock);
return newBlock.toBaseBlock();
}
}

View File

@ -308,7 +308,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
newState = newState.with(key, other.getState(key));
}
}
return this;
return newState;
}
@Override