From 7668481dea03f6c2ea1212b435f83d316a72ffeb Mon Sep 17 00:00:00 2001 From: cnlimiter Date: Wed, 12 Jun 2024 00:25:32 +0800 Subject: [PATCH] refactor(1.20.1-forged): MatterClusterItem rebuild 2 --- .../mods/avaritia/common/item/MatterClusterItem.java | 9 +++++---- src/main/resources/assets/avaritia/lang/en_us.json | 2 +- src/main/resources/assets/avaritia/lang/ru_ru.json | 2 +- src/main/resources/assets/avaritia/lang/zh_cn.json | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/committee/nova/mods/avaritia/common/item/MatterClusterItem.java b/src/main/java/committee/nova/mods/avaritia/common/item/MatterClusterItem.java index 113eee14..a174e2bb 100644 --- a/src/main/java/committee/nova/mods/avaritia/common/item/MatterClusterItem.java +++ b/src/main/java/committee/nova/mods/avaritia/common/item/MatterClusterItem.java @@ -15,6 +15,7 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.Tag; import net.minecraft.network.chat.Component; import net.minecraft.world.*; import net.minecraft.world.entity.Entity; @@ -46,7 +47,7 @@ public MatterClusterItem() { } public static int getClusterSize(ItemStack cluster) { - if (cluster.hasTag() || !cluster.getOrCreateTag().contains("items", 9)) { + if (cluster.hasTag() || !cluster.getOrCreateTag().contains("items", Tag.TAG_LIST)) { return Arrays.stream(readClusterInventory(cluster).items).mapToInt(ItemStack::getCount).sum(); } return 0; @@ -129,7 +130,7 @@ private static void writeClusterInventory(ItemStack cluster, SimpleContainer clu private static SimpleContainer readClusterInventory(ItemStack cluster) { SimpleContainer clusterInventory = new SimpleContainer(512); if (cluster.hasTag()) { - readItemStacksFromTag(clusterInventory.items, cluster.getOrCreateTag().getList("items", 10)); + readItemStacksFromTag(clusterInventory.items, cluster.getOrCreateTag().getList("items", Tag.TAG_COMPOUND)); } return clusterInventory; } @@ -153,10 +154,10 @@ private static void readItemStacksFromTag(ItemStack[] items, ListTag tagList) { @Override public void appendHoverText(ItemStack stack, Level worldIn, @NotNull List tooltip, @NotNull TooltipFlag flagIn) { - if (stack.hasTag() || !stack.getOrCreateTag().contains("items", 9)) { + if (stack.hasTag() || !stack.getOrCreateTag().contains("items", Tag.TAG_LIST)) { SimpleContainer inventory = readClusterInventory(stack); int total = Arrays.stream(inventory.items).mapToInt(ItemStack::getCount).sum(); - tooltip.add(Component.translatable("tooltip.matter_cluster.counter", total, Math.max(total, 4096))); + tooltip.add(Component.translatable("tooltip.matter_cluster.counter", total, Math.max(total, CAPACITY))); tooltip.add(Component.literal("")); if (Screen.hasShiftDown()) { Object2IntMap itemCounts = new Object2IntOpenHashMap<>(); diff --git a/src/main/resources/assets/avaritia/lang/en_us.json b/src/main/resources/assets/avaritia/lang/en_us.json index fbfc0cfe..84bac9b7 100644 --- a/src/main/resources/assets/avaritia/lang/en_us.json +++ b/src/main/resources/assets/avaritia/lang/en_us.json @@ -39,7 +39,7 @@ "tooltip.skullfire_sword.desc": "Beheads skeletons and scorches them black.", "tooltip.matter_cluster.desc": "Use to deconstruct.", "tooltip.matter_cluster.desc2": "Hold SHIFT for contents.", - "tooltip.matter_cluster.counter": "items", + "tooltip.matter_cluster.counter": "%s / %s items", "tooltip.star_fuel.desc": "A fuel for the stars.", "tooltip.neutron_gear.desc": "The secret of the tech renaissance...", "tooltip.infinity_nugget.desc": "Angel's tears...", diff --git a/src/main/resources/assets/avaritia/lang/ru_ru.json b/src/main/resources/assets/avaritia/lang/ru_ru.json index 27935872..0e08e622 100644 --- a/src/main/resources/assets/avaritia/lang/ru_ru.json +++ b/src/main/resources/assets/avaritia/lang/ru_ru.json @@ -157,7 +157,7 @@ "tooltip.infinity_catalyst.desc": "Всё в одном и одно во всём.", "tooltip.infinity_ingot.desc": "Вся мощь вселенной в твоей руке.", "tooltip.infinity_nugget.desc": "Слёзы ангела...", - "tooltip.matter_cluster.counter": "предметы", + "tooltip.matter_cluster.counter": "%s / %s предметы", "tooltip.matter_cluster.desc": "ПКМ для разрушения.", "tooltip.matter_cluster.desc2": "Зажмите SHIFT для подробностей.", "tooltip.neutron_gear.desc": "Секрет технического возрождения...", diff --git a/src/main/resources/assets/avaritia/lang/zh_cn.json b/src/main/resources/assets/avaritia/lang/zh_cn.json index d23586ef..6321c9ae 100644 --- a/src/main/resources/assets/avaritia/lang/zh_cn.json +++ b/src/main/resources/assets/avaritia/lang/zh_cn.json @@ -39,7 +39,7 @@ "tooltip.skullfire_sword.desc": "斩骷髅首级,后烧至焦黑。", "tooltip.matter_cluster.desc": "用于毁灭一切。", "tooltip.matter_cluster.desc2": "按下SHIFT显示详细信息。", - "tooltip.matter_cluster.counter": "物品", + "tooltip.matter_cluster.counter": "物品: %s / %s ", "tooltip.star_fuel.desc": "致密恒星的遗骸...", "tooltip.neutron_gear.desc": "科技复兴的秘密...", "tooltip.infinity_nugget.desc": "圣灵的眼泪...",