mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-04 15:41:38 +00:00
恢复MatchBlockTypeCondition识别ce自定义方块功能
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package net.momirealms.craftengine.core.plugin.context.condition;
|
package net.momirealms.craftengine.core.plugin.context.condition;
|
||||||
|
|
||||||
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.plugin.context.Condition;
|
import net.momirealms.craftengine.core.plugin.context.Condition;
|
||||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||||
import net.momirealms.craftengine.core.plugin.context.parameter.DirectContextParameters;
|
import net.momirealms.craftengine.core.plugin.context.parameter.DirectContextParameters;
|
||||||
@@ -28,7 +29,12 @@ public class MatchBlockTypeCondition<CTX extends Context> implements Condition<C
|
|||||||
@Override
|
@Override
|
||||||
public boolean test(CTX ctx) {
|
public boolean test(CTX ctx) {
|
||||||
Optional<BlockInWorld> block = ctx.getOptionalParameter(DirectContextParameters.BLOCK);
|
Optional<BlockInWorld> block = ctx.getOptionalParameter(DirectContextParameters.BLOCK);
|
||||||
return block.filter(blockInWorld -> MiscUtils.matchRegex(blockInWorld.type().asString(), this.ids, this.regexMatch)).isPresent();
|
Optional<ImmutableBlockState> customBlock = ctx.getOptionalParameter(DirectContextParameters.CUSTOM_BLOCK_STATE);
|
||||||
|
return block.filter(blockInWorld -> {
|
||||||
|
String key = customBlock.map(immutableBlockState ->
|
||||||
|
immutableBlockState.owner().value().id().asString()).orElseGet(() -> blockInWorld.type().asString());
|
||||||
|
return MiscUtils.matchRegex(key, this.ids, this.regexMatch);
|
||||||
|
}).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class FactoryImpl<CTX extends Context> implements ConditionFactory<CTX> {
|
public static class FactoryImpl<CTX extends Context> implements ConditionFactory<CTX> {
|
||||||
|
|||||||
Reference in New Issue
Block a user