Skip to content

Commit c882645

Browse files
authored
Use RandomPattern instead of RandomStatePattern (#3276)
1 parent a33e234 commit c882645

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomStatePatternParser.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
import com.sk89q.worldedit.extension.input.InputParseException;
2525
import com.sk89q.worldedit.extension.input.ParserContext;
2626
import com.sk89q.worldedit.function.pattern.Pattern;
27-
import com.sk89q.worldedit.function.pattern.RandomStatePattern;
27+
import com.sk89q.worldedit.function.pattern.RandomPattern;
2828
import com.sk89q.worldedit.internal.registry.InputParser;
2929
import com.sk89q.worldedit.world.block.BaseBlock;
30+
import com.sk89q.worldedit.world.block.BlockState;
3031
import com.sk89q.worldedit.world.block.FuzzyBlockState;
3132

3233
import java.util.Collections;
@@ -66,8 +67,15 @@ public Pattern parseFromInput(String input, ParserContext context) throws InputP
6667
if (block.getStates().size() == block.getBlockType().getPropertyMap().size()) {
6768
// they requested random with *, but didn't leave any states empty - simplify
6869
return block;
69-
} else if (block.toImmutableState() instanceof FuzzyBlockState) {
70-
return new RandomStatePattern((FuzzyBlockState) block.toImmutableState());
70+
// FAWE start - use RandomPattern instead of RandomStatePattern
71+
} else if (block.toImmutableState() instanceof FuzzyBlockState fbs) {
72+
RandomPattern randomPattern = new RandomPattern();
73+
fbs.getBlockType().getAllStates().stream()
74+
.filter(fbs::equalsFuzzy)
75+
.map(BlockState::toBaseBlock)
76+
.forEach(bb -> randomPattern.add(bb, 1.0));
77+
return randomPattern;
78+
// FAWE end
7179
} else {
7280
return null; // only should happen if parseLogic changes
7381
}

0 commit comments

Comments
 (0)