mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-19 15:09:15 +00:00
添加custom data的settings
This commit is contained in:
@@ -47,6 +47,7 @@ public class ItemSettings {
|
|||||||
Color dyeColor;
|
Color dyeColor;
|
||||||
@Nullable
|
@Nullable
|
||||||
Color fireworkColor;
|
Color fireworkColor;
|
||||||
|
Map<CustomDataType<?>, Object> customData = new IdentityHashMap<>(4);
|
||||||
|
|
||||||
private ItemSettings() {}
|
private ItemSettings() {}
|
||||||
|
|
||||||
@@ -108,6 +109,7 @@ public class ItemSettings {
|
|||||||
newSettings.dyeColor = settings.dyeColor;
|
newSettings.dyeColor = settings.dyeColor;
|
||||||
newSettings.fireworkColor = settings.fireworkColor;
|
newSettings.fireworkColor = settings.fireworkColor;
|
||||||
newSettings.ingredientSubstitutes = settings.ingredientSubstitutes;
|
newSettings.ingredientSubstitutes = settings.ingredientSubstitutes;
|
||||||
|
newSettings.customData = settings.customData;
|
||||||
return newSettings;
|
return newSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,73 +125,86 @@ public class ItemSettings {
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <T> T getCustomData(CustomDataType<T> type) {
|
||||||
|
return (T) this.customData.get(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearCustomData() {
|
||||||
|
this.customData.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void addCustomData(CustomDataType<T> key, T value) {
|
||||||
|
this.customData.put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
public ProjectileMeta projectileMeta() {
|
public ProjectileMeta projectileMeta() {
|
||||||
return projectileMeta;
|
return this.projectileMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean disableVanillaBehavior() {
|
public boolean disableVanillaBehavior() {
|
||||||
return disableVanillaBehavior;
|
return this.disableVanillaBehavior;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Repairable repairable() {
|
public Repairable repairable() {
|
||||||
return repairable;
|
return this.repairable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fuelTime() {
|
public int fuelTime() {
|
||||||
return fuelTime;
|
return this.fuelTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean renameable() {
|
public boolean renameable() {
|
||||||
return renameable;
|
return this.renameable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Key> tags() {
|
public Set<Key> tags() {
|
||||||
return tags;
|
return this.tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tristate dyeable() {
|
public Tristate dyeable() {
|
||||||
return dyeable;
|
return this.dyeable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canEnchant() {
|
public boolean canEnchant() {
|
||||||
return canEnchant;
|
return this.canEnchant;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AnvilRepairItem> repairItems() {
|
public List<AnvilRepairItem> repairItems() {
|
||||||
return anvilRepairItems;
|
return this.anvilRepairItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean respectRepairableComponent() {
|
public boolean respectRepairableComponent() {
|
||||||
return respectRepairableComponent;
|
return this.respectRepairableComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Key> ingredientSubstitutes() {
|
public List<Key> ingredientSubstitutes() {
|
||||||
return ingredientSubstitutes;
|
return this.ingredientSubstitutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public FoodData foodData() {
|
public FoodData foodData() {
|
||||||
return foodData;
|
return this.foodData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Key consumeReplacement() {
|
public Key consumeReplacement() {
|
||||||
return consumeReplacement;
|
return this.consumeReplacement;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public CraftRemainder craftRemainder() {
|
public CraftRemainder craftRemainder() {
|
||||||
return craftRemainder;
|
return this.craftRemainder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Helmet helmet() {
|
public Helmet helmet() {
|
||||||
return helmet;
|
return this.helmet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public ItemEquipment equipment() {
|
public ItemEquipment equipment() {
|
||||||
return equipment;
|
return this.equipment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -203,11 +218,11 @@ public class ItemSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<DamageSource> invulnerable() {
|
public List<DamageSource> invulnerable() {
|
||||||
return invulnerable;
|
return this.invulnerable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float compostProbability() {
|
public float compostProbability() {
|
||||||
return compostProbability;
|
return this.compostProbability;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemSettings fireworkColor(Color color) {
|
public ItemSettings fireworkColor(Color color) {
|
||||||
@@ -482,7 +497,7 @@ public class ItemSettings {
|
|||||||
registerFactory("ingredient-substitute", (value -> settings -> settings.ingredientSubstitutes(MiscUtils.getAsStringList(value).stream().map(Key::of).toList())));
|
registerFactory("ingredient-substitute", (value -> settings -> settings.ingredientSubstitutes(MiscUtils.getAsStringList(value).stream().map(Key::of).toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerFactory(String id, ItemSettings.Modifier.Factory factory) {
|
public static void registerFactory(String id, ItemSettings.Modifier.Factory factory) {
|
||||||
FACTORIES.put(id, factory);
|
FACTORIES.put(id, factory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package net.momirealms.craftengine.core.util;
|
||||||
|
|
||||||
|
public class CustomDataType<T> {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user