mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-27 19:09:08 +00:00
支持覆写原版物品模型
This commit is contained in:
@@ -177,6 +177,7 @@ warning.config.item.missing_material: "<yellow>Issue found in file <arg:0> - The
|
|||||||
warning.config.item.invalid_material: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid material type '<arg:2>'.</yellow>"
|
warning.config.item.invalid_material: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid material type '<arg:2>'.</yellow>"
|
||||||
warning.config.item.invalid_custom_model_data: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using a negative custom model data '<arg:2>' which is invalid.</yellow>"
|
warning.config.item.invalid_custom_model_data: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using a negative custom model data '<arg:2>' which is invalid.</yellow>"
|
||||||
warning.config.item.bad_custom_model_data: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using a custom model data '<arg:2>' that is too large. It's recommended to use a value lower than 16,777,216.</yellow>"
|
warning.config.item.bad_custom_model_data: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using a custom model data '<arg:2>' that is too large. It's recommended to use a value lower than 16,777,216.</yellow>"
|
||||||
|
warning.config.item.item_model.conflict: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid 'item-model' option because this item model has been occupied by a vanilla item.</yellow>"
|
||||||
warning.config.item.custom_model_data_conflict: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using a custom model data '<arg:2>' that has been occupied by item '<arg:3>'.</yellow>"
|
warning.config.item.custom_model_data_conflict: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using a custom model data '<arg:2>' that has been occupied by item '<arg:3>'.</yellow>"
|
||||||
warning.config.item.invalid_component: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using a non-existing component type '<arg:2>'.</yellow>"
|
warning.config.item.invalid_component: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using a non-existing component type '<arg:2>'.</yellow>"
|
||||||
warning.config.item.missing_model_id: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'custom-model-data' or 'item-model' argument.</yellow>"
|
warning.config.item.missing_model_id: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'custom-model-data' or 'item-model' argument.</yellow>"
|
||||||
@@ -395,7 +396,6 @@ warning.config.function.remove_cooldown.missing_id: "<yellow>Issue found in file
|
|||||||
warning.config.selector.missing_type: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'type' argument for selector.</yellow>"
|
warning.config.selector.missing_type: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'type' argument for selector.</yellow>"
|
||||||
warning.config.selector.invalid_type: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is using an invalid selector type '<arg:2>'.</yellow>"
|
warning.config.selector.invalid_type: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is using an invalid selector type '<arg:2>'.</yellow>"
|
||||||
warning.config.selector.invalid_target: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is using an invalid selector target '<arg:2>'.</yellow>"
|
warning.config.selector.invalid_target: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is using an invalid selector target '<arg:2>'.</yellow>"
|
||||||
warning.config.resource_pack.item_model.conflict.vanilla: "<yellow>Failed to generate item model for '<arg:0>' because this item model has been occupied by a vanilla item.</yellow>"
|
|
||||||
warning.config.resource_pack.item_model.already_exist: "<yellow>Failed to generate item model for '<arg:0>' because the file '<arg:1>' already exists.</yellow>"
|
warning.config.resource_pack.item_model.already_exist: "<yellow>Failed to generate item model for '<arg:0>' because the file '<arg:1>' already exists.</yellow>"
|
||||||
warning.config.resource_pack.model.generation.already_exist: "<yellow>Failed to generate model because the model file '<arg:0>' already exists.</yellow>"
|
warning.config.resource_pack.model.generation.already_exist: "<yellow>Failed to generate model because the model file '<arg:0>' already exists.</yellow>"
|
||||||
warning.config.resource_pack.generation.missing_font_texture: "<yellow>Font '<arg:0>' is missing required texture: '<arg:1>'</yellow>"
|
warning.config.resource_pack.generation.missing_font_texture: "<yellow>Font '<arg:0>' is missing required texture: '<arg:1>'</yellow>"
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ warning.config.item.invalid_custom_model_data: "<yellow>在文件 <arg:0> 发现
|
|||||||
warning.config.item.bad_custom_model_data: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 使用的自定义模型数据 '<arg:2>' 数值过大 建议使用小于 16,777,216 的值</yellow>"
|
warning.config.item.bad_custom_model_data: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 使用的自定义模型数据 '<arg:2>' 数值过大 建议使用小于 16,777,216 的值</yellow>"
|
||||||
warning.config.item.custom_model_data_conflict: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 使用的自定义模型数据 '<arg:2>' 已被物品 '<arg:3>' 占用</yellow>"
|
warning.config.item.custom_model_data_conflict: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 使用的自定义模型数据 '<arg:2>' 已被物品 '<arg:3>' 占用</yellow>"
|
||||||
warning.config.item.invalid_component: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 使用了未知的数据组件 '<arg:2>'</yellow>"
|
warning.config.item.invalid_component: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 使用了未知的数据组件 '<arg:2>'</yellow>"
|
||||||
|
warning.config.item.item_model.conflict: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 使用了无效的 'item-model' 选项. 这个 item-model 已经存在对应的原版物品.</yellow>"
|
||||||
warning.config.item.missing_model_id: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 缺少必需的 'custom-model-data' 或 'item-model' 参数</yellow>"
|
warning.config.item.missing_model_id: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 缺少必需的 'custom-model-data' 或 'item-model' 参数</yellow>"
|
||||||
warning.config.item.missing_model: "<yellow>在文件 <arg:0> 中发现问题 - 物品 '<arg:1>' 缺少支持 1.21.4+ 资源包必需的 'model' 配置项</yellow>"
|
warning.config.item.missing_model: "<yellow>在文件 <arg:0> 中发现问题 - 物品 '<arg:1>' 缺少支持 1.21.4+ 资源包必需的 'model' 配置项</yellow>"
|
||||||
warning.config.item.behavior.missing_type: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 的行为配置缺少必需的 'type' 参数</yellow>"
|
warning.config.item.behavior.missing_type: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 的行为配置缺少必需的 'type' 参数</yellow>"
|
||||||
@@ -393,7 +394,6 @@ warning.config.function.remove_cooldown.missing_id: "<yellow>在文件 <arg:0>
|
|||||||
warning.config.selector.missing_type: "<yellow>在文件 <arg:0> 中发现问题 - 配置项 '<arg:1>' 缺少选择器必需的 'type' 参数</yellow>"
|
warning.config.selector.missing_type: "<yellow>在文件 <arg:0> 中发现问题 - 配置项 '<arg:1>' 缺少选择器必需的 'type' 参数</yellow>"
|
||||||
warning.config.selector.invalid_type: "<yellow>在文件 <arg:0> 中发现问题 - 配置项 '<arg:1>' 使用了无效的选择器类型 '<arg:2>'</yellow>"
|
warning.config.selector.invalid_type: "<yellow>在文件 <arg:0> 中发现问题 - 配置项 '<arg:1>' 使用了无效的选择器类型 '<arg:2>'</yellow>"
|
||||||
warning.config.selector.invalid_target: "<yellow>在文件 <arg:0> 中发现问题 - 配置项 '<arg:1>' 使用了无效的选择器目标 '<arg:2>'</yellow>"
|
warning.config.selector.invalid_target: "<yellow>在文件 <arg:0> 中发现问题 - 配置项 '<arg:1>' 使用了无效的选择器目标 '<arg:2>'</yellow>"
|
||||||
warning.config.resource_pack.item_model.conflict.vanilla: "<yellow>无法为 '<arg:0>' 生成物品模型,因为该物品模型已被原版物品占用</yellow>"
|
|
||||||
warning.config.resource_pack.item_model.already_exist: "<yellow>无法为 '<arg:0>' 生成物品模型,因为文件 '<arg:1>' 已存在</yellow>"
|
warning.config.resource_pack.item_model.already_exist: "<yellow>无法为 '<arg:0>' 生成物品模型,因为文件 '<arg:1>' 已存在</yellow>"
|
||||||
warning.config.resource_pack.model.generation.already_exist: "<yellow>无法生成模型,因为模型文件 '<arg:0>' 已存在</yellow>"
|
warning.config.resource_pack.model.generation.already_exist: "<yellow>无法生成模型,因为模型文件 '<arg:0>' 已存在</yellow>"
|
||||||
warning.config.resource_pack.generation.missing_font_texture: "<yellow>字体'<arg:0>'缺少必要纹理: '<arg:1>'</yellow>"
|
warning.config.resource_pack.generation.missing_font_texture: "<yellow>字体'<arg:0>'缺少必要纹理: '<arg:1>'</yellow>"
|
||||||
|
|||||||
@@ -327,12 +327,12 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
UniqueKey uniqueId = UniqueKey.create(id);
|
UniqueKey uniqueId = UniqueKey.create(id);
|
||||||
|
// 判断是不是原版物品
|
||||||
// register for recipes
|
|
||||||
boolean isVanillaItem = isVanillaItem(id);
|
boolean isVanillaItem = isVanillaItem(id);
|
||||||
Key material = Key.from(isVanillaItem ? id.value() : ResourceConfigUtils.requireNonEmptyStringOrThrow(section.get("material"), "warning.config.item.missing_material").toLowerCase(Locale.ENGLISH));
|
Key material = Key.from(isVanillaItem ? id.value() : ResourceConfigUtils.requireNonEmptyStringOrThrow(section.get("material"), "warning.config.item.missing_material").toLowerCase(Locale.ENGLISH));
|
||||||
Key clientBoundMaterial = section.containsKey("client-bound-material") ? Key.from(section.get("client-bound-material").toString().toLowerCase(Locale.ENGLISH)) : material;
|
Key clientBoundMaterial = section.containsKey("client-bound-material") ? Key.from(section.get("client-bound-material").toString().toLowerCase(Locale.ENGLISH)) : material;
|
||||||
int customModelData = ResourceConfigUtils.getAsInt(section.getOrDefault("custom-model-data", 0), "custom-model-data");
|
// 如果是原版物品,那么custom-model-data只能是0,即使用户设置了其他值
|
||||||
|
int customModelData = isVanillaItem ? 0 : ResourceConfigUtils.getAsInt(section.getOrDefault("custom-model-data", 0), "custom-model-data");
|
||||||
boolean clientBoundModel = section.containsKey("client-bound-model") ? ResourceConfigUtils.getAsBoolean(section.get("client-bound-data"), "client-bound-data") : Config.globalClientboundModel();
|
boolean clientBoundModel = section.containsKey("client-bound-model") ? ResourceConfigUtils.getAsBoolean(section.get("client-bound-data"), "client-bound-data") : Config.globalClientboundModel();
|
||||||
if (customModelData < 0) {
|
if (customModelData < 0) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.item.invalid_custom_model_data", String.valueOf(customModelData));
|
throw new LocalizedResourceConfigException("warning.config.item.invalid_custom_model_data", String.valueOf(customModelData));
|
||||||
@@ -341,53 +341,46 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
|||||||
throw new LocalizedResourceConfigException("warning.config.item.bad_custom_model_data", String.valueOf(customModelData));
|
throw new LocalizedResourceConfigException("warning.config.item.bad_custom_model_data", String.valueOf(customModelData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// item-model值
|
||||||
Key itemModelKey = null;
|
Key itemModelKey = null;
|
||||||
|
|
||||||
CustomItem.Builder<I> itemBuilder = createPlatformItemBuilder(uniqueId, material, clientBoundMaterial);
|
CustomItem.Builder<I> itemBuilder = createPlatformItemBuilder(uniqueId, material, clientBoundMaterial);
|
||||||
boolean hasItemModelSection = section.containsKey("item-model");
|
boolean hasItemModelSection = section.containsKey("item-model");
|
||||||
|
|
||||||
// To get at least one model provider
|
// 如果custom-model-data不为0
|
||||||
// Sets some basic model info
|
|
||||||
if (customModelData > 0) {
|
if (customModelData > 0) {
|
||||||
if (clientBoundModel) {
|
if (clientBoundModel) itemBuilder.clientBoundDataModifier(new CustomModelDataModifier<>(customModelData));
|
||||||
itemBuilder.clientBoundDataModifier(new CustomModelDataModifier<>(customModelData));
|
else itemBuilder.dataModifier(new CustomModelDataModifier<>(customModelData));
|
||||||
} else {
|
|
||||||
itemBuilder.dataModifier(new CustomModelDataModifier<>(customModelData));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Requires the item to have model before apply item-model
|
// 如果没有item-model选项被配置,同时这个物品又含有 model 区域
|
||||||
else if (!hasItemModelSection && section.containsKey("model") && VersionHelper.isOrAbove1_21_2()) {
|
else if (!hasItemModelSection && section.containsKey("model") && VersionHelper.isOrAbove1_21_2()) {
|
||||||
// check server version here because components require 1.21.2+
|
// 那么使用物品id当成item-model的值
|
||||||
// customize or use the id
|
|
||||||
itemModelKey = Key.from(section.getOrDefault("item-model", id.toString()).toString());
|
itemModelKey = Key.from(section.getOrDefault("item-model", id.toString()).toString());
|
||||||
|
// 但是有个前提,id必须是有效的resource location
|
||||||
if (ResourceLocation.isValid(itemModelKey.toString())) {
|
if (ResourceLocation.isValid(itemModelKey.toString())) {
|
||||||
if (clientBoundModel) {
|
if (clientBoundModel) itemBuilder.clientBoundDataModifier(new ItemModelModifier<>(itemModelKey));
|
||||||
itemBuilder.clientBoundDataModifier(new ItemModelModifier<>(itemModelKey));
|
else itemBuilder.dataModifier(new ItemModelModifier<>(itemModelKey));
|
||||||
} else {
|
|
||||||
itemBuilder.dataModifier(new ItemModelModifier<>(itemModelKey));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
itemModelKey = null;
|
itemModelKey = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果有item-model
|
||||||
if (hasItemModelSection && VersionHelper.isOrAbove1_21_2()) {
|
if (hasItemModelSection && VersionHelper.isOrAbove1_21_2()) {
|
||||||
itemModelKey = Key.from(section.get("item-model").toString());
|
itemModelKey = Key.from(section.get("item-model").toString());
|
||||||
if (clientBoundModel) {
|
if (clientBoundModel) itemBuilder.clientBoundDataModifier(new ItemModelModifier<>(itemModelKey));
|
||||||
itemBuilder.clientBoundDataModifier(new ItemModelModifier<>(itemModelKey));
|
else itemBuilder.dataModifier(new ItemModelModifier<>(itemModelKey));
|
||||||
} else {
|
|
||||||
itemBuilder.dataModifier(new ItemModelModifier<>(itemModelKey));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get item data
|
// 应用物品数据
|
||||||
applyDataFunctions(MiscUtils.castToMap(section.get("data"), true), itemBuilder::dataModifier);
|
applyDataFunctions(MiscUtils.castToMap(section.get("data"), true), itemBuilder::dataModifier);
|
||||||
applyDataFunctions(MiscUtils.castToMap(section.get("client-bound-data"), true), itemBuilder::clientBoundDataModifier);
|
applyDataFunctions(MiscUtils.castToMap(section.get("client-bound-data"), true), itemBuilder::clientBoundDataModifier);
|
||||||
|
|
||||||
// Add custom it here to make sure that id is always applied
|
// 如果不是原版物品,那么加入ce的标识符
|
||||||
if (!isVanillaItem)
|
if (!isVanillaItem)
|
||||||
itemBuilder.dataModifier(new IdModifier<>(id));
|
itemBuilder.dataModifier(new IdModifier<>(id));
|
||||||
|
|
||||||
|
// 构建自定义物品
|
||||||
CustomItem<I> customItem = itemBuilder
|
CustomItem<I> customItem = itemBuilder
|
||||||
.behaviors(ItemBehaviors.fromObj(pack, path, id, ResourceConfigUtils.get(section, "behavior", "behaviors")))
|
.behaviors(ItemBehaviors.fromObj(pack, path, id, ResourceConfigUtils.get(section, "behavior", "behaviors")))
|
||||||
.settings(Optional.ofNullable(ResourceConfigUtils.get(section, "settings"))
|
.settings(Optional.ofNullable(ResourceConfigUtils.get(section, "settings"))
|
||||||
@@ -396,32 +389,32 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
|||||||
.orElse(ItemSettings.of().canPlaceRelatedVanillaBlock(isVanillaItem)))
|
.orElse(ItemSettings.of().canPlaceRelatedVanillaBlock(isVanillaItem)))
|
||||||
.events(EventFunctions.parseEvents(ResourceConfigUtils.get(section, "events", "event")))
|
.events(EventFunctions.parseEvents(ResourceConfigUtils.get(section, "events", "event")))
|
||||||
.build();
|
.build();
|
||||||
|
// 添加到缓存
|
||||||
addCustomItem(customItem);
|
addCustomItem(customItem);
|
||||||
|
|
||||||
// add it to category
|
// 如果有类别,则添加
|
||||||
if (section.containsKey("category")) {
|
if (section.containsKey("category")) {
|
||||||
AbstractItemManager.this.plugin.itemBrowserManager().addExternalCategoryMember(id, MiscUtils.getAsStringList(section.get("category")).stream().map(Key::of).toList());
|
AbstractItemManager.this.plugin.itemBrowserManager().addExternalCategoryMember(id, MiscUtils.getAsStringList(section.get("category")).stream().map(Key::of).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 不处理原版物品的模型
|
// 模型配置区域,如果这里被配置了,那么用户必须要配置custom-model-data或item-model
|
||||||
if (isVanillaItem) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// model part, can be null
|
|
||||||
// but if it exists, either custom model data or item model should be configured
|
|
||||||
Map<String, Object> modelSection = MiscUtils.castToMap(section.get("model"), true);
|
Map<String, Object> modelSection = MiscUtils.castToMap(section.get("model"), true);
|
||||||
Map<String, Object> legacyModelSection = MiscUtils.castToMap(section.get("legacy-model"), true);
|
Map<String, Object> legacyModelSection = MiscUtils.castToMap(section.get("legacy-model"), true);
|
||||||
if (modelSection == null && legacyModelSection == null) {
|
if (modelSection == null && legacyModelSection == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 如果设置了model,但是没有模型值?
|
|
||||||
if (customModelData == 0 && itemModelKey == null) {
|
boolean needsModelSection = isModernFormatRequired() || (needsLegacyCompatibility() && legacyModelSection == null);
|
||||||
throw new LocalizedResourceConfigException("warning.config.item.missing_model_id");
|
// 只对自定义物品有这个限制
|
||||||
|
if (!isVanillaItem) {
|
||||||
|
// 既没有模型值也没有item-model
|
||||||
|
if (customModelData == 0 && itemModelKey == null) {
|
||||||
|
throw new LocalizedResourceConfigException("warning.config.item.missing_model_id");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 1.21.4+必须要配置model区域
|
|
||||||
if (isModernFormatRequired() && modelSection == null) {
|
// 1.21.4+必须要配置model区域,如果不需要高版本兼容,则可以只写legacy-model
|
||||||
|
if (needsModelSection && modelSection == null) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.item.missing_model");
|
throw new LocalizedResourceConfigException("warning.config.item.missing_model");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,13 +422,14 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
|||||||
ItemModel modernModel = null;
|
ItemModel modernModel = null;
|
||||||
// 旧版格式
|
// 旧版格式
|
||||||
TreeSet<LegacyOverridesModel> legacyOverridesModels = null;
|
TreeSet<LegacyOverridesModel> legacyOverridesModels = null;
|
||||||
|
// 如果需要支持新版item model 或者用户需要旧版本兼容,但是没配置legacy-model
|
||||||
if (isModernFormatRequired() || (needsLegacyCompatibility() && legacyModelSection == null)) {
|
if (needsModelSection) {
|
||||||
modernModel = ItemModels.fromMap(modelSection);
|
modernModel = ItemModels.fromMap(modelSection);
|
||||||
for (ModelGeneration generation : modernModel.modelsToGenerate()) {
|
for (ModelGeneration generation : modernModel.modelsToGenerate()) {
|
||||||
prepareModelGeneration(generation);
|
prepareModelGeneration(generation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 如果需要旧版本兼容
|
||||||
if (needsLegacyCompatibility()) {
|
if (needsLegacyCompatibility()) {
|
||||||
if (legacyModelSection != null) {
|
if (legacyModelSection != null) {
|
||||||
LegacyItemModel legacyItemModel = LegacyItemModel.fromMap(legacyModelSection, customModelData);
|
LegacyItemModel legacyItemModel = LegacyItemModel.fromMap(legacyModelSection, customModelData);
|
||||||
@@ -452,48 +446,61 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isVanillaItemModel = itemModelKey != null && AbstractPackManager.PRESET_ITEMS.containsKey(itemModelKey);
|
// 自定义物品的model处理
|
||||||
|
if (!isVanillaItem) {
|
||||||
// use custom model data
|
// 这个item-model是否存在,且是原版item-model
|
||||||
if (customModelData != 0) {
|
boolean isVanillaItemModel = itemModelKey != null && AbstractPackManager.PRESET_ITEMS.containsKey(itemModelKey);
|
||||||
// use custom model data
|
// 使用了自定义模型值
|
||||||
// 其实这很奇怪,因为1.21.2以下并不支持item model,但是如果强行配置,那么不阻拦
|
if (customModelData != 0) {
|
||||||
Key finalBaseModel = isVanillaItemModel ? itemModelKey : clientBoundMaterial;
|
// 如果用户主动设置了item-model且为原版物品,则使用item-model为基础模型,否则使用其视觉材质对应的item-model
|
||||||
Map<Integer, Key> conflict = AbstractItemManager.this.cmdConflictChecker.computeIfAbsent(finalBaseModel, k -> new HashMap<>());
|
Key finalBaseModel = isVanillaItemModel ? itemModelKey : clientBoundMaterial;
|
||||||
if (conflict.containsKey(customModelData)) {
|
// 检查cmd冲突
|
||||||
throw new LocalizedResourceConfigException("warning.config.item.custom_model_data_conflict", String.valueOf(customModelData), conflict.get(customModelData).toString());
|
Map<Integer, Key> conflict = AbstractItemManager.this.cmdConflictChecker.computeIfAbsent(finalBaseModel, k -> new HashMap<>());
|
||||||
|
if (conflict.containsKey(customModelData)) {
|
||||||
|
throw new LocalizedResourceConfigException("warning.config.item.custom_model_data_conflict", String.valueOf(customModelData), conflict.get(customModelData).toString());
|
||||||
|
}
|
||||||
|
conflict.put(customModelData, id);
|
||||||
|
// 添加新版item model
|
||||||
|
if (isModernFormatRequired() && modernModel != null) {
|
||||||
|
TreeMap<Integer, ModernItemModel> map = AbstractItemManager.this.modernOverrides.computeIfAbsent(finalBaseModel, k -> new TreeMap<>());
|
||||||
|
map.put(customModelData, new ModernItemModel(
|
||||||
|
modernModel,
|
||||||
|
ResourceConfigUtils.getAsBoolean(section.getOrDefault("oversized-in-gui", true), "oversized-in-gui"),
|
||||||
|
ResourceConfigUtils.getAsBoolean(section.getOrDefault("hand-animation-on-swap", true), "hand-animation-on-swap")
|
||||||
|
));
|
||||||
|
}
|
||||||
|
// 添加旧版 overrides
|
||||||
|
if (needsLegacyCompatibility() && legacyOverridesModels != null && !legacyOverridesModels.isEmpty()) {
|
||||||
|
TreeSet<LegacyOverridesModel> lom = AbstractItemManager.this.legacyOverrides.computeIfAbsent(finalBaseModel, k -> new TreeSet<>());
|
||||||
|
lom.addAll(legacyOverridesModels);
|
||||||
|
}
|
||||||
|
} else if (isVanillaItemModel) {
|
||||||
|
throw new LocalizedResourceConfigException("warning.config.item.item_model.conflict", itemModelKey.asString());
|
||||||
}
|
}
|
||||||
conflict.put(customModelData, id);
|
|
||||||
// Parse models
|
// 使用了item-model组件,且不是原版物品的
|
||||||
if (isModernFormatRequired() && modernModel != null) {
|
if (itemModelKey != null && !isVanillaItemModel) {
|
||||||
TreeMap<Integer, ModernItemModel> map = AbstractItemManager.this.modernOverrides.computeIfAbsent(finalBaseModel, k -> new TreeMap<>());
|
if (isModernFormatRequired() && modernModel != null) {
|
||||||
map.put(customModelData, new ModernItemModel(
|
AbstractItemManager.this.modernItemModels1_21_4.put(itemModelKey, new ModernItemModel(
|
||||||
|
modernModel,
|
||||||
|
ResourceConfigUtils.getAsBoolean(section.getOrDefault("oversized-in-gui", true), "oversized-in-gui"),
|
||||||
|
ResourceConfigUtils.getAsBoolean(section.getOrDefault("hand-animation-on-swap", true), "hand-animation-on-swap")
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if (Config.packMaxVersion().isAtOrAbove(MinecraftVersions.V1_21_2) && needsLegacyCompatibility() && legacyOverridesModels != null && !legacyOverridesModels.isEmpty()) {
|
||||||
|
TreeSet<LegacyOverridesModel> lom = AbstractItemManager.this.modernItemModels1_21_2.computeIfAbsent(itemModelKey, k -> new TreeSet<>());
|
||||||
|
lom.addAll(legacyOverridesModels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 原版物品的item model覆写
|
||||||
|
if (isModernFormatRequired()) {
|
||||||
|
AbstractItemManager.this.modernItemModels1_21_4.put(id, new ModernItemModel(
|
||||||
modernModel,
|
modernModel,
|
||||||
ResourceConfigUtils.getAsBoolean(section.getOrDefault("oversized-in-gui", true), "oversized-in-gui"),
|
ResourceConfigUtils.getAsBoolean(section.getOrDefault("oversized-in-gui", true), "oversized-in-gui"),
|
||||||
ResourceConfigUtils.getAsBoolean(section.getOrDefault("hand-animation-on-swap", true), "hand-animation-on-swap")
|
ResourceConfigUtils.getAsBoolean(section.getOrDefault("hand-animation-on-swap", true), "hand-animation-on-swap")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if (needsLegacyCompatibility() && legacyOverridesModels != null && !legacyOverridesModels.isEmpty()) {
|
|
||||||
TreeSet<LegacyOverridesModel> lom = AbstractItemManager.this.legacyOverrides.computeIfAbsent(finalBaseModel, k -> new TreeSet<>());
|
|
||||||
lom.addAll(legacyOverridesModels);
|
|
||||||
}
|
|
||||||
} else if (isVanillaItemModel) {
|
|
||||||
throw new IllegalArgumentException("You are not allowed to use vanilla 'item-model' without specifying a 'custom-model-data'.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// use item model, but not a vanilla model
|
|
||||||
if (itemModelKey != null && !isVanillaItemModel) {
|
|
||||||
if (isModernFormatRequired() && modernModel != null) {
|
|
||||||
AbstractItemManager.this.modernItemModels1_21_4.put(itemModelKey, new ModernItemModel(
|
|
||||||
modernModel,
|
|
||||||
ResourceConfigUtils.getAsBoolean(section.getOrDefault("oversized-in-gui", true), "oversized-in-gui"),
|
|
||||||
ResourceConfigUtils.getAsBoolean(section.getOrDefault("hand-animation-on-swap", true), "hand-animation-on-swap")
|
|
||||||
));
|
|
||||||
}
|
|
||||||
if (Config.packMaxVersion().isAtOrAbove(MinecraftVersions.V1_21_2) && needsLegacyCompatibility() && legacyOverridesModels != null && !legacyOverridesModels.isEmpty()) {
|
|
||||||
TreeSet<LegacyOverridesModel> lom = AbstractItemManager.this.modernItemModels1_21_2.computeIfAbsent(itemModelKey, k -> new TreeSet<>());
|
|
||||||
lom.addAll(legacyOverridesModels);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -643,10 +643,11 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
this.generateItemModels(generatedPackPath, this.plugin.itemManager());
|
this.generateItemModels(generatedPackPath, this.plugin.itemManager());
|
||||||
this.generateItemModels(generatedPackPath, this.plugin.blockManager());
|
this.generateItemModels(generatedPackPath, this.plugin.blockManager());
|
||||||
this.generateBlockOverrides(generatedPackPath);
|
this.generateBlockOverrides(generatedPackPath);
|
||||||
this.generateLegacyItemOverrides(generatedPackPath);
|
// 一定要先生成item-model再生成overrides
|
||||||
this.generateModernItemOverrides(generatedPackPath, revisions::add);
|
|
||||||
this.generateModernItemModels1_21_2(generatedPackPath);
|
this.generateModernItemModels1_21_2(generatedPackPath);
|
||||||
this.generateModernItemModels1_21_4(generatedPackPath, revisions::add);
|
this.generateModernItemModels1_21_4(generatedPackPath, revisions::add);
|
||||||
|
this.generateLegacyItemOverrides(generatedPackPath);
|
||||||
|
this.generateModernItemOverrides(generatedPackPath, revisions::add);
|
||||||
this.generateOverrideSounds(generatedPackPath);
|
this.generateOverrideSounds(generatedPackPath);
|
||||||
this.generateCustomSounds(generatedPackPath);
|
this.generateCustomSounds(generatedPackPath);
|
||||||
this.generateClientLang(generatedPackPath);
|
this.generateClientLang(generatedPackPath);
|
||||||
@@ -1769,12 +1770,6 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
Key itemModelPath = entry.getKey();
|
Key itemModelPath = entry.getKey();
|
||||||
TreeSet<LegacyOverridesModel> legacyOverridesModels = entry.getValue();
|
TreeSet<LegacyOverridesModel> legacyOverridesModels = entry.getValue();
|
||||||
|
|
||||||
// 检测item model合法性
|
|
||||||
if (PRESET_MODERN_MODELS_ITEM.containsKey(itemModelPath) || PRESET_LEGACY_MODELS_ITEM.containsKey(itemModelPath)) {
|
|
||||||
TranslationManager.instance().log("warning.config.resource_pack.item_model.conflict.vanilla", itemModelPath.asString());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 要检查目标生成路径是否已经存在模型,如果存在模型,应该只为其生成overrides
|
// 要检查目标生成路径是否已经存在模型,如果存在模型,应该只为其生成overrides
|
||||||
Path itemPath = generatedPackPath
|
Path itemPath = generatedPackPath
|
||||||
.resolve("assets")
|
.resolve("assets")
|
||||||
@@ -1836,11 +1831,6 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
.resolve(key.namespace())
|
.resolve(key.namespace())
|
||||||
.resolve("items")
|
.resolve("items")
|
||||||
.resolve(key.value() + ".json");
|
.resolve(key.value() + ".json");
|
||||||
|
|
||||||
if (PRESET_ITEMS.containsKey(key)) {
|
|
||||||
TranslationManager.instance().log("warning.config.resource_pack.item_model.conflict.vanilla", key.asString());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (Files.exists(itemPath)) {
|
if (Files.exists(itemPath)) {
|
||||||
TranslationManager.instance().log("warning.config.resource_pack.item_model.already_exist", key.asString(), itemPath.toAbsolutePath().toString());
|
TranslationManager.instance().log("warning.config.resource_pack.item_model.already_exist", key.asString(), itemPath.toAbsolutePath().toString());
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
|
|
||||||
# Project settings
|
# Project settings
|
||||||
# Rule: [major update].[feature update].[bug fix]
|
# Rule: [major update].[feature update].[bug fix]
|
||||||
project_version=0.0.59.11
|
project_version=0.0.60
|
||||||
config_version=41
|
config_version=41
|
||||||
lang_version=22
|
lang_version=22
|
||||||
project_group=net.momirealms
|
project_group=net.momirealms
|
||||||
|
|||||||
Reference in New Issue
Block a user