9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2026-01-06 15:52:03 +00:00

再修复一些问题

This commit is contained in:
XiaoMoMi
2025-09-29 01:16:44 +08:00
parent c7df9ced63
commit ab68fa13d0
11 changed files with 22 additions and 39 deletions

View File

@@ -257,7 +257,7 @@ warning.config.block.state.missing_properties: "<yellow>Problem in Datei <arg:0>
warning.config.block.state.missing_appearances: "<yellow>Problem in Datei <arg:0> gefunden - Beim Block '<arg:1>' fehlt der erforderliche 'appearances'-Abschnitt für 'states'.</yellow>"
warning.config.block.state.variant.invalid_appearance: "<yellow>Problem in Datei <arg:0> gefunden - Der Block '<arg:1>' hat einen Fehler, dass die Variante '<arg:2>' eine nicht existierende Appearance '<arg:3>' verwendet.</yellow>"
warning.config.block.state.invalid_vanilla: "<yellow>Problem in Datei <arg:0> gefunden - Der Block '<arg:1>' verwendet einen ungültigen Vanilla-Block-State '<arg:2>'.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>Problem in Datei <arg:0> gefunden - Der Block '<arg:1>' verwendet einen nicht verfügbaren Vanilla-Block-State '<arg:2>'. Bitte gib diesen State in der mappings.yml frei.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>Problem in Datei <arg:0> gefunden - Der Block '<arg:1>' verwendet einen nicht verfügbaren Vanilla-Block-State '<arg:2>'. Bitte gib diesen State in der block-state-mappings frei.</yellow>"
warning.config.block.state.invalid_vanilla_id: "<yellow>Problem in Datei <arg:0> gefunden - Der Block '<arg:1>' verwendet einen Vanilla-Block-State '<arg:2>', der den verfügbaren Slot-Bereich '0~<arg:3>' überschreitet.</yellow>"
warning.config.block.state.id.conflict: "<yellow>Problem in Datei <arg:0> gefunden - Der Block '<arg:1>' konnte den echten Block-State für '<arg:2>' nicht binden, da der State bereits von '<arg:3>' belegt ist.</yellow>"
warning.config.block.state.model.missing_path: "<yellow>Problem in Datei <arg:0> gefunden - Beim Block '<arg:1>' fehlt die erforderliche 'path'-Option für 'model'.</yellow>"

View File

@@ -129,6 +129,7 @@ warning.config.image.codepoint.exhausted: "<yellow>Issue found in file <arg:0> -
warning.config.image.invalid_codepoint_grid: "<yellow>Issue found in file <arg:0> - Image '<arg:1>' has an invalid 'chars' codepoint grid.</yellow>"
warning.config.image.invalid_char: "<yellow>Issue found in file <arg:0> - Image '<arg:1>' has a char parameter containing combining characters, which may result in image splitting.</yellow>"
warning.config.image.invalid_hex_value: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' is using a unicode character '<arg:2>' that is not a valid hexadecimal (radix 16) value.</yellow>"
warning.config.image.invalid_unicode_string: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' is using an incorrect unicode string '<arg:2>'.</yellow>"
warning.config.recipe.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated recipe '<arg:1>'. Please check if there is the same configuration in other files.</yellow>"
warning.config.recipe.missing_type: "<yellow>Issue found in file <arg:0> - The recipe '<arg:1>' is missing the required 'type' argument.</yellow>"
warning.config.recipe.invalid_type: "<yellow>Issue found in file <arg:0> - The recipe '<arg:1>' is using an invalid recipe type '<arg:2>'.</yellow>"
@@ -276,7 +277,7 @@ warning.config.block.state.entity_renderer.better_model.missing_model: "<yellow>
warning.config.block.state.entity_renderer.model_engine.missing_model: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'model' argument for 'model_engine' entity renderer.</yellow>"
warning.config.block.state.variant.invalid_appearance: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' has an error that the variant '<arg:2>' is using a non-existing appearance '<arg:3>'.</yellow>"
warning.config.block.state.invalid_vanilla: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using an invalid vanilla block state '<arg:2>'.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using an unavailable vanilla block state '<arg:2>'. Please free that state in mappings.yml.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using an unavailable vanilla block state '<arg:2>'. Please free that state in block-state-mappings.</yellow>"
warning.config.block.state.invalid_vanilla_id: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using a vanilla block state '<arg:2>' that exceeds the available slot range '0~<arg:3>'.</yellow>"
warning.config.block.state.invalid_id: "<yellow>Issue found in file <arg:0> - The block state ID range (<arg:2>) used by block '<arg:1>' is outside the valid range of 0 to <arg:3>. Please add more server-side blocks in 'config.yml' if the current slots are exhausted.</yellow>"
warning.config.block.state.id.conflict: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' failed to bind real block state '<arg:4>' for '<arg:2>' as the state has been occupied by '<arg:3>'.</yellow>"

View File

@@ -180,7 +180,7 @@ warning.config.block.state.missing_properties: "<yellow>Problema encontrado en e
warning.config.block.state.missing_appearances: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' carece de la sección requerida 'appearances' para 'states'.</yellow>"
warning.config.block.state.variant.invalid_appearance: "<yellow>Problema encontrado en el archivo <arg:0> - Hay un error en el bloque '<arg:1>' donde la variante '<arg:2>' está usando una apariencia inexistente '<arg:3>'.</yellow>"
warning.config.block.state.invalid_vanilla: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' está usando un estado de bloque vanilla inválido '<arg:2>'.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' está usando un estado de bloque vanilla no disponible '<arg:2>'. Por favor libera este estado en el archivo mappings.yml.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' está usando un estado de bloque vanilla no disponible '<arg:2>'. Por favor libera este estado en el archivo block-state-mappings.</yellow>"
warning.config.block.state.invalid_vanilla_id: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' está usando un estado de bloque vanilla '<arg:2>' que excede el rango de slots disponible '0~<arg:3>'.</yellow>"
warning.config.block.state.id.conflict: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' falló al vincular el estado de bloque real para '<arg:2>' porque está ocupado por el estado '<arg:3>'.</yellow>"
warning.config.block.state.model.missing_path: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' carece de la opción requerida 'path' para 'model'.</yellow>"

View File

@@ -230,7 +230,7 @@ warning.config.block.state.missing_properties: "<yellow>Проблема най
warning.config.block.state.missing_appearances: "<yellow>Проблема найдена в файле <arg:0> - В блоке '<arg:1>' отсутствует необходимый 'appearances' раздел для 'states'.</yellow>"
warning.config.block.state.variant.invalid_appearance: "<yellow>Проблема найдена в файле <arg:0> - Блок '<arg:1>' имеет ошибку, что вариант '<arg:2>' использует несуществующий внешний вид '<arg:3>'.</yellow>"
warning.config.block.state.invalid_vanilla: "<yellow>Проблема найдена в файле <arg:0> - Блок '<arg:1>' имеет недействительное состояние ванильного блока '<arg:2>'.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>Проблема найдена в файле <arg:0> - Блок '<arg:1>' использует недоступное состояние ванильного блока '<arg:2>'. Пожалуйста, освободите это состояние в mappings.yml.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>Проблема найдена в файле <arg:0> - Блок '<arg:1>' использует недоступное состояние ванильного блока '<arg:2>'. Пожалуйста, освободите это состояние в block-state-mappings.</yellow>"
warning.config.block.state.invalid_vanilla_id: "<yellow>Проблема найдена в файле <arg:0> - Блок '<arg:1>' использует состояние ванильного блока '<arg:2>', что превышает доступный диапазон слотов '0~<arg:3>'.</yellow>"
warning.config.block.state.id.conflict: "<yellow>Проблема найдена в файле <arg:0> - Блоку '<arg:1>' не удалось привязать реальное состояние блока для '<arg:2>', так как состояние занято '<arg:3>'.</yellow>"
warning.config.block.state.model.missing_path: "<yellow>Проблема найдена в файле <arg:0> - В блоке '<arg:1>' отсутствует необходимый 'path' опция для 'model'.</yellow>"

View File

@@ -178,7 +178,7 @@ warning.config.block.state.missing_properties: "<yellow><arg:0> dosyasında soru
warning.config.block.state.missing_appearances: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu, 'states' için gerekli 'appearances' bölümü eksik.</yellow>"
warning.config.block.state.variant.invalid_appearance: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğunda, '<arg:2>' varyantının var olmayan bir görünüm '<arg:3>' kullandığı bir hata var.</yellow>"
warning.config.block.state.invalid_vanilla: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu geçersiz bir vanilya blok durumu '<arg:2>' kullanıyor.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu kullanılamayan bir vanilya blok durumu '<arg:2>' kullanıyor. Lütfen bu durumu mappings.yml dosyasında serbest bırakın.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu kullanılamayan bir vanilya blok durumu '<arg:2>' kullanıyor. Lütfen bu durumu block-state-mappings dosyasında serbest bırakın.</yellow>"
warning.config.block.state.invalid_vanilla_id: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu, mevcut yuva aralığı '0~<arg:3>' aşan bir vanilya blok durumu '<arg:2>' kullanıyor.</yellow>"
warning.config.block.state.id.conflict: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu, durum '<arg:3>' tarafından işgal edildiği için '<arg:2>' için gerçek blok durumu bağlamada başarısız oldu.</yellow>"
warning.config.block.state.model.missing_path: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu, 'model' için gerekli 'path' seçeneği eksik.</yellow>"

View File

@@ -266,7 +266,7 @@ warning.config.block.state.missing_properties: "<yellow>在文件 <arg:0> 发现
warning.config.block.state.missing_appearances: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'states' 缺少必需的 'appearances' 段落</yellow>"
warning.config.block.state.variant.invalid_appearance: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的变体 '<arg:2>' 使用了不存在的 appearance '<arg:3>'</yellow>"
warning.config.block.state.invalid_vanilla: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 使用了无效的原版方块状态 '<arg:2>'</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 使用了不可用的原版方块状态 '<arg:2>' 请在 mappings.yml 中释放该状态</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 使用了不可用的原版方块状态 '<arg:2>' 请在 block-state-mappings 中释放该状态</yellow>"
warning.config.block.state.invalid_vanilla_id: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 使用的原版方块状态 '<arg:2>' 超出可用槽位范围 '0~<arg:3>'</yellow>"
warning.config.block.state.id.conflict: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 无法为 '<arg:2>' 绑定真实方块状态 '<arg:4>' 因该状态已被 '<arg:3>' 占用</yellow>"
warning.config.block.state.invalid_id: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 使用的真实方块状态 '<arg:2>' 超出可用槽位范围 '0~<arg:3>' 如果槽位已用尽 请在 config.yml 中添加更多服务端侧方块</yellow>"

View File

@@ -383,6 +383,8 @@ public abstract class AbstractBlockManager extends AbstractModelGenerator implem
Map<String, Property<?>> properties = singleState ? Map.of() : parseBlockProperties(ResourceConfigUtils.getAsMap(ResourceConfigUtils.requireNonNullOrThrow(stateSection.get("properties"), "warning.config.block.state.missing_properties"), "properties"));
// 注册方块容器
Holder.Reference<CustomBlock> holder = ((WritableRegistry<CustomBlock>) BuiltInRegistries.BLOCK).getOrRegisterForHolder(ResourceKey.create(BuiltInRegistries.BLOCK.key().location(), id));
// 先绑定无效方块
holder.bindValue(new InactiveCustomBlock(holder));
// 根据properties生成variant provider
BlockStateVariantProvider variantProvider = new BlockStateVariantProvider(holder, (owner, propertyMap) -> {
@@ -455,8 +457,6 @@ public abstract class AbstractBlockManager extends AbstractModelGenerator implem
LootTable.fromMap(ResourceConfigUtils.getAsMapOrNull(section.get("loot"), "loot"))
);
BlockBehavior blockBehavior = createBlockBehavior(customBlock, MiscUtils.getAsMapList(ResourceConfigUtils.get(section, "behavior", "behaviors")));
customBlock.setBehavior(blockBehavior);
holder.bindValue(customBlock);
// 单状态
if (singleState) {
@@ -555,6 +555,10 @@ public abstract class AbstractBlockManager extends AbstractModelGenerator implem
}
}
// 一定要到最后再绑定
customBlock.setBehavior(blockBehavior);
holder.bindValue(customBlock);
// 添加方块
AbstractBlockManager.this.byId.put(customBlock.id(), customBlock);

View File

@@ -1,6 +1,7 @@
package net.momirealms.craftengine.core.block;
import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap;
import net.momirealms.craftengine.core.block.behavior.EmptyBlockBehavior;
import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.sparrow.nbt.CompoundTag;
@@ -18,6 +19,7 @@ public final class InactiveCustomBlock extends AbstractCustomBlock {
public ImmutableBlockState getBlockState(CompoundTag nbt) {
return this.cachedData.computeIfAbsent(nbt, k -> {
ImmutableBlockState state = new ImmutableBlockState(super.holder, new Reference2ObjectArrayMap<>());
state.setBehavior(EmptyBlockBehavior.INSTANCE);
state.setNbtToSave(state.toNbtToSave(nbt));
return state;
});

View File

@@ -6,14 +6,12 @@ import java.util.regex.Pattern;
import java.util.stream.IntStream;
public class CharacterUtils {
private static final Pattern PATTERN = Pattern.compile("[\\p{Mn}\\p{Me}\\p{Mc}\\p{Cf}]");
private CharacterUtils() {}
public static char[] decodeUnicodeToChars(String unicodeString) {
int count = unicodeString.length() / 6;
if (unicodeString.length() % 6 != 0) {
throw new LocalizedResourceConfigException("warning.config.image.invalid_unicode_string_length");
throw new LocalizedResourceConfigException("warning.config.image.invalid_unicode_string", unicodeString);
}
char[] chars = new char[count];
for (int i = 0, j = 0; j < count; i += 6, j++) {
@@ -71,29 +69,6 @@ public class CharacterUtils {
return builder.toString();
}
public static boolean containsCombinedCharacter(String input) {
if (input == null || input.isEmpty() || input.length() == 1) return false;
for (int i = 0; i < input.length();) {
int codePoint = input.codePointAt(i);
i += Character.charCount(codePoint);
int type = Character.getType(codePoint);
if (type == Character.NON_SPACING_MARK ||
type == Character.ENCLOSING_MARK ||
type == Character.COMBINING_SPACING_MARK ||
type == Character.FORMAT ||
type == Character.CONTROL ||
type == Character.SURROGATE ||
type == Character.PRIVATE_USE ||
PATTERN.matcher(new String(Character.toChars(codePoint))).find()
) return true;
if (i < input.length()) {
int nextCodePoint = input.codePointAt(i);
if (Character.isSurrogatePair(Character.toChars(codePoint)[0], Character.toChars(nextCodePoint)[0])) return true;
}
}
return false;
}
public static String replaceBackslashWithSlash(String input) {
if (input == null || input.isEmpty()) {
return input;

View File

@@ -38,9 +38,11 @@ public final class DefaultBlockEntitySerializer {
} else {
BlockPos pos = BlockEntity.readPosAndVerify(data, chunk.chunkPos());
ImmutableBlockState blockState = chunk.getBlockState(pos);
BlockEntity blockEntity = type.factory().create(pos, blockState);
blockEntity.loadCustomData(data);
blockEntities.add(blockEntity);
if (blockState.blockEntityType() == type) {
BlockEntity blockEntity = type.factory().create(pos, blockState);
blockEntity.loadCustomData(data);
blockEntities.add(blockEntity);
}
}
}
return blockEntities;

View File

@@ -74,8 +74,7 @@ public final class DefaultSectionSerializer {
key = Key.of(id);
}
Holder<CustomBlock> owner = BuiltInRegistries.BLOCK.get(key).orElseGet(() -> {
Holder.Reference<CustomBlock> holder = ((WritableRegistry<CustomBlock>) BuiltInRegistries.BLOCK).registerForHolder(
ResourceKey.create(BuiltInRegistries.BLOCK.key().location(), key));
Holder.Reference<CustomBlock> holder = ((WritableRegistry<CustomBlock>) BuiltInRegistries.BLOCK).registerForHolder(ResourceKey.create(BuiltInRegistries.BLOCK.key().location(), key));
InactiveCustomBlock inactiveBlock = new InactiveCustomBlock(holder);
holder.bindValue(inactiveBlock);
return holder;