mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-06 15:52:03 +00:00
fix i18n loading sequence
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
package net.momirealms.craftengine.core.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record AnvilRepairItem(List<String> targets, int amount, double percent) {
|
||||
}
|
||||
@@ -19,6 +19,10 @@ public interface CustomItem<I> extends BuildableItem<I> {
|
||||
|
||||
ItemSettings settings();
|
||||
|
||||
default boolean is(Key tag) {
|
||||
return settings().tags().contains(tag);
|
||||
}
|
||||
|
||||
default Item<I> buildItem(Player player) {
|
||||
return buildItem(new ItemBuildContext(player, ContextHolder.EMPTY));
|
||||
}
|
||||
|
||||
@@ -17,13 +17,14 @@ public class ItemSettings {
|
||||
@Nullable
|
||||
EquipmentGeneration equipment;
|
||||
boolean canRepair = true;
|
||||
List<AnvilRepairItem> anvilRepairItems = List.of();
|
||||
|
||||
private ItemSettings() {}
|
||||
|
||||
public <I> List<ItemModifier<I>> modifiers() {
|
||||
ArrayList<ItemModifier<I>> modifiers = new ArrayList<>();
|
||||
if (VersionHelper.isVersionNewerThan1_21_2() && this.equipment != null && this.equipment.modernData() != null) modifiers.add(new EquippableModifier<>(this.equipment.modernData()));
|
||||
|
||||
// TODO 1.20
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
@@ -41,6 +42,7 @@ public class ItemSettings {
|
||||
newSettings.tags = settings.tags;
|
||||
newSettings.equipment = settings.equipment;
|
||||
newSettings.canRepair = settings.canRepair;
|
||||
newSettings.anvilRepairItems = settings.anvilRepairItems;
|
||||
return newSettings;
|
||||
}
|
||||
|
||||
@@ -68,11 +70,20 @@ public class ItemSettings {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public List<AnvilRepairItem> repairItems() {
|
||||
return anvilRepairItems;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EquipmentGeneration equipment() {
|
||||
return equipment;
|
||||
}
|
||||
|
||||
public ItemSettings repairItems(List<AnvilRepairItem> items) {
|
||||
this.anvilRepairItems = items;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemSettings canRepair(boolean canRepair) {
|
||||
this.canRepair = canRepair;
|
||||
return this;
|
||||
@@ -113,6 +124,17 @@ public class ItemSettings {
|
||||
boolean bool = (boolean) value;
|
||||
return settings -> settings.canRepair(bool);
|
||||
}));
|
||||
registerFactory("anvil-repair-item", (value -> {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Map<String, Object>> materials = (List<Map<String, Object>>) value;
|
||||
List<AnvilRepairItem> anvilRepairItemList = new ArrayList<>();
|
||||
for (Map<String, Object> material : materials) {
|
||||
int amount = MiscUtils.getAsInt(material.getOrDefault("amount", 0));
|
||||
double percent = MiscUtils.getAsDouble(material.getOrDefault("percent", 0));
|
||||
anvilRepairItemList.add(new AnvilRepairItem(MiscUtils.getAsStringList(material.get("target")), amount, percent));
|
||||
}
|
||||
return settings -> settings.repairItems(anvilRepairItemList);
|
||||
}));
|
||||
registerFactory("fuel-time", (value -> {
|
||||
int intValue = MiscUtils.getAsInt(value);
|
||||
return settings -> settings.fuelTime(intValue);
|
||||
|
||||
@@ -2,14 +2,14 @@ package net.momirealms.craftengine.core.pack;
|
||||
|
||||
public class LoadingSequence {
|
||||
public static final int TEMPLATE = 0;
|
||||
public static final int BLOCK = 10;
|
||||
public static final int ITEM = 20;
|
||||
public static final int FURNITURE = 30;
|
||||
public static final int FONT = 40;
|
||||
public static final int RECIPE = 50;
|
||||
public static final int CATEGORY = 60;
|
||||
public static final int TRANSLATION = 70;
|
||||
public static final int LANG = 80;
|
||||
public static final int LANG = 10;
|
||||
public static final int TRANSLATION = 20;
|
||||
public static final int BLOCK = 30;
|
||||
public static final int ITEM = 40;
|
||||
public static final int FURNITURE = 50;
|
||||
public static final int FONT = 60;
|
||||
public static final int RECIPE = 70;
|
||||
public static final int CATEGORY = 80;
|
||||
public static final int SOUND = 90;
|
||||
public static final int JUKEBOX_SONG = 100;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user