mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 01:49:30 +00:00
添加新模板
This commit is contained in:
@@ -1,5 +1,23 @@
|
||||
# This file contains some useful template data. If you have good ideas, you are welcome to contribute your template!
|
||||
|
||||
# These templates let you ditch the real custom_model_data on the server side.
|
||||
# Instead, we use client side components sent via packets to control how items look.
|
||||
templates#client_bound_model:
|
||||
default:item/client_bound_custom_model_data:
|
||||
custom-model-data: "${custom_model_data}"
|
||||
data:
|
||||
remove-components:
|
||||
- minecraft:custom_model_data
|
||||
client-bound-data:
|
||||
custom-model-data: "${custom_model_data}"
|
||||
default:item/client_bound_item_model:
|
||||
item-model: "${item_model}"
|
||||
data:
|
||||
remove-components:
|
||||
- minecraft:item_model
|
||||
client-bound-data:
|
||||
item-model: "${item_model}"
|
||||
|
||||
# blocks
|
||||
templates#models#block:
|
||||
# template: default:model/cube_all
|
||||
|
||||
@@ -478,6 +478,10 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
||||
boolean value = TypeUtils.checkType(obj, Boolean.class);
|
||||
return new UnbreakableModifier<>(value);
|
||||
}, "unbreakable");
|
||||
registerDataType((obj) -> {
|
||||
int customModelData = ResourceConfigUtils.getAsInt(obj, "custom-model-data");
|
||||
return new CustomModelDataModifier<>(customModelData);
|
||||
}, "custom-model-data");
|
||||
registerDataType((obj) -> {
|
||||
Map<String, Object> data = MiscUtils.castToMap(obj, false);
|
||||
List<Enchantment> enchantments = new ArrayList<>();
|
||||
@@ -494,6 +498,14 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
||||
String pattern = data.get("pattern").toString().toLowerCase(Locale.ENGLISH);
|
||||
return new TrimModifier<>(material, pattern);
|
||||
}, "trim");
|
||||
registerDataType((obj) -> {
|
||||
Map<String, Object> data = MiscUtils.castToMap(obj, false);
|
||||
Map<String, TextProvider> arguments = new HashMap<>();
|
||||
for (Map.Entry<String, Object> entry : data.entrySet()) {
|
||||
arguments.put(entry.getKey(), TextProviders.fromString(entry.getValue().toString()));
|
||||
}
|
||||
return new ArgumentModifier<>(arguments);
|
||||
}, "args", "argument", "arguments");
|
||||
if (VersionHelper.isOrAbove1_20_5()) {
|
||||
registerDataType((obj) -> {
|
||||
Map<String, Object> data = MiscUtils.castToMap(obj, false);
|
||||
@@ -521,21 +533,15 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
||||
String id = obj.toString();
|
||||
return new TooltipStyleModifier<>(Key.of(id));
|
||||
}, "tooltip-style");
|
||||
}
|
||||
if (VersionHelper.isOrAbove1_21_2()) {
|
||||
registerDataType((obj) -> {
|
||||
Map<String, Object> data = MiscUtils.castToMap(obj, false);
|
||||
return new EquippableModifier<>(EquipmentData.fromMap(data));
|
||||
}, "equippable");
|
||||
registerDataType((obj) -> {
|
||||
String id = obj.toString();
|
||||
return new ItemModelModifier<>(Key.of(id));
|
||||
}, "item-model");
|
||||
}
|
||||
registerDataType((obj) -> {
|
||||
Map<String, Object> data = MiscUtils.castToMap(obj, false);
|
||||
Map<String, TextProvider> arguments = new HashMap<>();
|
||||
for (Map.Entry<String, Object> entry : data.entrySet()) {
|
||||
arguments.put(entry.getKey(), TextProviders.fromString(entry.getValue().toString()));
|
||||
}
|
||||
return new ArgumentModifier<>(arguments);
|
||||
}, "args", "argument", "arguments");
|
||||
}
|
||||
|
||||
protected void processModelRecursively(
|
||||
|
||||
@@ -36,6 +36,7 @@ public class ItemSettings {
|
||||
Key consumeReplacement = null;
|
||||
Key craftRemainder = null;
|
||||
List<DamageSource> invulnerable = List.of();
|
||||
boolean canEnchant = true;
|
||||
|
||||
private ItemSettings() {}
|
||||
|
||||
@@ -75,6 +76,7 @@ public class ItemSettings {
|
||||
newSettings.consumeReplacement = settings.consumeReplacement;
|
||||
newSettings.craftRemainder = settings.craftRemainder;
|
||||
newSettings.invulnerable = settings.invulnerable;
|
||||
newSettings.canEnchant = settings.canEnchant;
|
||||
return newSettings;
|
||||
}
|
||||
|
||||
@@ -118,6 +120,10 @@ public class ItemSettings {
|
||||
return dyeable;
|
||||
}
|
||||
|
||||
public boolean canEnchant() {
|
||||
return canEnchant;
|
||||
}
|
||||
|
||||
public List<AnvilRepairItem> repairItems() {
|
||||
return anvilRepairItems;
|
||||
}
|
||||
@@ -171,6 +177,11 @@ public class ItemSettings {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemSettings canEnchant(boolean canEnchant) {
|
||||
this.canEnchant = canEnchant;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemSettings renameable(boolean renameable) {
|
||||
this.renameable = renameable;
|
||||
return this;
|
||||
@@ -241,6 +252,10 @@ public class ItemSettings {
|
||||
boolean bool = (boolean) value;
|
||||
return settings -> settings.canRepair(bool);
|
||||
}));
|
||||
registerFactory("enchantable", (value -> {
|
||||
boolean bool = (boolean) value;
|
||||
return settings -> settings.canEnchant(bool);
|
||||
}));
|
||||
registerFactory("renameable", (value -> {
|
||||
boolean bool = (boolean) value;
|
||||
return settings -> settings.renameable(bool);
|
||||
|
||||
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Project settings
|
||||
# Rule: [major update].[feature update].[bug fix]
|
||||
project_version=0.0.57.1
|
||||
project_version=0.0.57.2
|
||||
config_version=37
|
||||
lang_version=16
|
||||
project_group=net.momirealms
|
||||
|
||||
Reference in New Issue
Block a user