Skip to content

Commit

Permalink
refactor(1.20.1-forged): MatterClusterItem rebuild 2
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlimiter committed Jun 11, 2024
1 parent 4cf4956 commit 7668481
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -153,10 +154,10 @@ private static void readItemStacksFromTag(ItemStack[] items, ListTag tagList) {

@Override
public void appendHoverText(ItemStack stack, Level worldIn, @NotNull List<Component> 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<Item> itemCounts = new Object2IntOpenHashMap<>();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/avaritia/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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...",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/avaritia/lang/ru_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "Секрет технического возрождения...",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/avaritia/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "圣灵的眼泪...",
Expand Down

0 comments on commit 7668481

Please sign in to comment.