9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2026-01-03 22:26:16 +00:00

修正一些问题

This commit is contained in:
XiaoMoMi
2025-08-23 18:28:07 +08:00
parent 05e3dd545f
commit c8a6b3b8d5
11 changed files with 22 additions and 20 deletions

View File

@@ -125,6 +125,7 @@ public abstract class AbstractPackManager implements PackManager {
loadInternalList("textures", "", VANILLA_TEXTURES::add);
VANILLA_MODELS.add(Key.of("minecraft", "builtin/entity"));
VANILLA_MODELS.add(Key.of("minecraft", "item/player_head"));
for (int i = 0; i < 256; i++) {
VANILLA_TEXTURES.add(Key.of("minecraft", "font/unicode_page_" + String.format("%02x", i)));
}

View File

@@ -420,7 +420,6 @@ public class Config {
emoji$contexts$sign = config.getBoolean("emoji.contexts.sign", true);
emoji$max_emojis_per_parse = config.getInt("emoji.max-emojis-per-parse", 32);
firstTime = false;
}

View File

@@ -1,6 +1,5 @@
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.Context;
import net.momirealms.craftengine.core.plugin.context.parameter.DirectContextParameters;
@@ -29,10 +28,7 @@ public class MatchBlockTypeCondition<CTX extends Context> implements Condition<C
@Override
public boolean test(CTX ctx) {
Optional<BlockInWorld> block = ctx.getOptionalParameter(DirectContextParameters.BLOCK);
if (block.isEmpty()) return false;
Optional<ImmutableBlockState> customBlock = ctx.getOptionalParameter(DirectContextParameters.CUSTOM_BLOCK_STATE);
Key key = customBlock.isPresent() ? customBlock.get().owner().value().id() : block.get().type();
return MiscUtils.matchObject(key, this.regexMatch, this.ids);
return block.filter(blockInWorld -> MiscUtils.matchRegex(blockInWorld.type().asString(), this.ids, this.regexMatch)).isPresent();
}
public static class FactoryImpl<CTX extends Context> implements ConditionFactory<CTX> {

View File

@@ -28,9 +28,7 @@
@Override
public boolean test(CTX ctx) {
Optional<Entity> entity = ctx.getOptionalParameter(DirectContextParameters.ENTITY);
if (entity.isEmpty()) return false;
Key key = entity.get().type();
return MiscUtils.matchObject(key, this.regexMatch, this.ids);
return entity.filter(value -> MiscUtils.matchRegex(value.type().asString(), this.ids, this.regexMatch)).isPresent();
}
public static class FactoryImpl<CTX extends Context> implements ConditionFactory<CTX> {

View File

@@ -28,9 +28,7 @@ public class MatchItemCondition<CTX extends Context> implements Condition<CTX> {
@Override
public boolean test(CTX ctx) {
Optional<Item<?>> item = ctx.getOptionalParameter(DirectContextParameters.ITEM_IN_HAND);
if (item.isEmpty()) return false;
Key key = item.get().id();
return MiscUtils.matchObject(key, this.regexMatch, this.ids);
return item.filter(value -> MiscUtils.matchRegex(value.id().asString(), this.ids, this.regexMatch)).isPresent();
}
public static class FactoryImpl<CTX extends Context> implements ConditionFactory<CTX> {

View File

@@ -9,7 +9,7 @@ public enum Debugger {
COMMON(Config::debugCommon),
PACKET(Config::debugPacket),
FURNITURE(Config::debugFurniture),
RESOURCE_PACK(Config::debugFurniture),
RESOURCE_PACK(Config::debugResourcePack),
ITEM(Config::debugItem);
private final Supplier<Boolean> condition;

View File

@@ -151,8 +151,7 @@ public class MiscUtils {
}
}
public static boolean matchObject(Key key, boolean regexMatch, Set<String> ids) {
String id = key.toString();
public static boolean matchRegex(String id, Set<String> ids, boolean regexMatch) {
if (regexMatch) {
for (String regex : ids) {
if (id.matches(regex)) {