mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-06 15:52:03 +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!
|
# 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
|
# blocks
|
||||||
templates#models#block:
|
templates#models#block:
|
||||||
# template: default:model/cube_all
|
# template: default:model/cube_all
|
||||||
|
|||||||
@@ -478,6 +478,10 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
|||||||
boolean value = TypeUtils.checkType(obj, Boolean.class);
|
boolean value = TypeUtils.checkType(obj, Boolean.class);
|
||||||
return new UnbreakableModifier<>(value);
|
return new UnbreakableModifier<>(value);
|
||||||
}, "unbreakable");
|
}, "unbreakable");
|
||||||
|
registerDataType((obj) -> {
|
||||||
|
int customModelData = ResourceConfigUtils.getAsInt(obj, "custom-model-data");
|
||||||
|
return new CustomModelDataModifier<>(customModelData);
|
||||||
|
}, "custom-model-data");
|
||||||
registerDataType((obj) -> {
|
registerDataType((obj) -> {
|
||||||
Map<String, Object> data = MiscUtils.castToMap(obj, false);
|
Map<String, Object> data = MiscUtils.castToMap(obj, false);
|
||||||
List<Enchantment> enchantments = new ArrayList<>();
|
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);
|
String pattern = data.get("pattern").toString().toLowerCase(Locale.ENGLISH);
|
||||||
return new TrimModifier<>(material, pattern);
|
return new TrimModifier<>(material, pattern);
|
||||||
}, "trim");
|
}, "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()) {
|
if (VersionHelper.isOrAbove1_20_5()) {
|
||||||
registerDataType((obj) -> {
|
registerDataType((obj) -> {
|
||||||
Map<String, Object> data = MiscUtils.castToMap(obj, false);
|
Map<String, Object> data = MiscUtils.castToMap(obj, false);
|
||||||
@@ -521,21 +533,15 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
|||||||
String id = obj.toString();
|
String id = obj.toString();
|
||||||
return new TooltipStyleModifier<>(Key.of(id));
|
return new TooltipStyleModifier<>(Key.of(id));
|
||||||
}, "tooltip-style");
|
}, "tooltip-style");
|
||||||
}
|
|
||||||
if (VersionHelper.isOrAbove1_21_2()) {
|
|
||||||
registerDataType((obj) -> {
|
registerDataType((obj) -> {
|
||||||
Map<String, Object> data = MiscUtils.castToMap(obj, false);
|
Map<String, Object> data = MiscUtils.castToMap(obj, false);
|
||||||
return new EquippableModifier<>(EquipmentData.fromMap(data));
|
return new EquippableModifier<>(EquipmentData.fromMap(data));
|
||||||
}, "equippable");
|
}, "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(
|
protected void processModelRecursively(
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public class ItemSettings {
|
|||||||
Key consumeReplacement = null;
|
Key consumeReplacement = null;
|
||||||
Key craftRemainder = null;
|
Key craftRemainder = null;
|
||||||
List<DamageSource> invulnerable = List.of();
|
List<DamageSource> invulnerable = List.of();
|
||||||
|
boolean canEnchant = true;
|
||||||
|
|
||||||
private ItemSettings() {}
|
private ItemSettings() {}
|
||||||
|
|
||||||
@@ -75,6 +76,7 @@ public class ItemSettings {
|
|||||||
newSettings.consumeReplacement = settings.consumeReplacement;
|
newSettings.consumeReplacement = settings.consumeReplacement;
|
||||||
newSettings.craftRemainder = settings.craftRemainder;
|
newSettings.craftRemainder = settings.craftRemainder;
|
||||||
newSettings.invulnerable = settings.invulnerable;
|
newSettings.invulnerable = settings.invulnerable;
|
||||||
|
newSettings.canEnchant = settings.canEnchant;
|
||||||
return newSettings;
|
return newSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,6 +120,10 @@ public class ItemSettings {
|
|||||||
return dyeable;
|
return dyeable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canEnchant() {
|
||||||
|
return canEnchant;
|
||||||
|
}
|
||||||
|
|
||||||
public List<AnvilRepairItem> repairItems() {
|
public List<AnvilRepairItem> repairItems() {
|
||||||
return anvilRepairItems;
|
return anvilRepairItems;
|
||||||
}
|
}
|
||||||
@@ -171,6 +177,11 @@ public class ItemSettings {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemSettings canEnchant(boolean canEnchant) {
|
||||||
|
this.canEnchant = canEnchant;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ItemSettings renameable(boolean renameable) {
|
public ItemSettings renameable(boolean renameable) {
|
||||||
this.renameable = renameable;
|
this.renameable = renameable;
|
||||||
return this;
|
return this;
|
||||||
@@ -241,6 +252,10 @@ public class ItemSettings {
|
|||||||
boolean bool = (boolean) value;
|
boolean bool = (boolean) value;
|
||||||
return settings -> settings.canRepair(bool);
|
return settings -> settings.canRepair(bool);
|
||||||
}));
|
}));
|
||||||
|
registerFactory("enchantable", (value -> {
|
||||||
|
boolean bool = (boolean) value;
|
||||||
|
return settings -> settings.canEnchant(bool);
|
||||||
|
}));
|
||||||
registerFactory("renameable", (value -> {
|
registerFactory("renameable", (value -> {
|
||||||
boolean bool = (boolean) value;
|
boolean bool = (boolean) value;
|
||||||
return settings -> settings.renameable(bool);
|
return settings -> settings.renameable(bool);
|
||||||
|
|||||||
@@ -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.57.1
|
project_version=0.0.57.2
|
||||||
config_version=37
|
config_version=37
|
||||||
lang_version=16
|
lang_version=16
|
||||||
project_group=net.momirealms
|
project_group=net.momirealms
|
||||||
|
|||||||
Reference in New Issue
Block a user