aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/AttributeShardAdder.java
blob: 27856ab846046fb0e11c35b5a29cd25966f817ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package de.hysky.skyblocker.skyblock.item.slottext.adders;

import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.item.slottext.SlotText;
import de.hysky.skyblocker.skyblock.item.slottext.SimpleSlotTextAdder;
import de.hysky.skyblocker.utils.ItemUtils;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.screen.slot.Slot;
import net.minecraft.text.Text;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class AttributeShardAdder extends SimpleSlotTextAdder {
	private static final Object2ObjectMap<String, String> ID_2_SHORT_NAME = new Object2ObjectOpenHashMap<>();

	static {
		//Weapons
		ID_2_SHORT_NAME.put("arachno", "A");
		ID_2_SHORT_NAME.put("attack_speed", "AS");
		ID_2_SHORT_NAME.put("blazing", "BL");
		ID_2_SHORT_NAME.put("combo", "C");
		ID_2_SHORT_NAME.put("elite", "E");
		ID_2_SHORT_NAME.put("ender", "EN");
		ID_2_SHORT_NAME.put("ignition", "I");
		ID_2_SHORT_NAME.put("life_recovery", "HE"); //HE for Healing since LR should go to Life regen since thats more useful
		ID_2_SHORT_NAME.put("mana_steal", "MS");
		ID_2_SHORT_NAME.put("midas_touch", "MT");
		ID_2_SHORT_NAME.put("undead", "U");

		//Swords & Bows
		ID_2_SHORT_NAME.put("warrior", "W");
		ID_2_SHORT_NAME.put("deadeye", "DE");

		//Armor or Equipment
		ID_2_SHORT_NAME.put("arachno_resistance", "AR");
		ID_2_SHORT_NAME.put("blazing_resistance", "BR");
		ID_2_SHORT_NAME.put("breeze", "B");
		ID_2_SHORT_NAME.put("dominance", "D");
		ID_2_SHORT_NAME.put("ender_resistance", "ER");
		ID_2_SHORT_NAME.put("experience", "XP");
		ID_2_SHORT_NAME.put("fortitude", "F");
		ID_2_SHORT_NAME.put("life_regeneration", "LR");
		ID_2_SHORT_NAME.put("lifeline", "L");
		ID_2_SHORT_NAME.put("magic_find", "MF");
		ID_2_SHORT_NAME.put("mana_pool", "MP");
		ID_2_SHORT_NAME.put("mana_regeneration", "MR");
		ID_2_SHORT_NAME.put("mending", "VI"); //Vitality
		ID_2_SHORT_NAME.put("speed", "S");
		ID_2_SHORT_NAME.put("undead_resistance", "UR");
		ID_2_SHORT_NAME.put("veteran", "V");

		//Fishing Gear
		ID_2_SHORT_NAME.put("blazing_fortune", "BF");
		ID_2_SHORT_NAME.put("fishing_experience", "FE");
		ID_2_SHORT_NAME.put("infection", "IF");
		ID_2_SHORT_NAME.put("double_hook", "DH");
		ID_2_SHORT_NAME.put("fisherman", "FM");
		ID_2_SHORT_NAME.put("fishing_speed", "FS");
		ID_2_SHORT_NAME.put("hunter", "H");
		ID_2_SHORT_NAME.put("trophy_hunter", "TH");
	}

	public AttributeShardAdder() {
		super();
	}

	@Override
	public @NotNull List<SlotText> getText(@Nullable Slot slot, @NotNull ItemStack stack, int slotId) {
		NbtCompound customData = ItemUtils.getCustomData(stack);

		if (!ItemUtils.getItemId(stack).equals("ATTRIBUTE_SHARD")) return List.of();

		NbtCompound attributesTag = customData.getCompound("attributes");
		String[] attributes = attributesTag.getKeys().toArray(String[]::new);

		if (attributes.length != 1) return List.of();
		String attributeId = attributes[0];
		int attributeLevel = attributesTag.getInt(attributeId);
		String attributeInitials = ID_2_SHORT_NAME.getOrDefault(attributeId, "");

		return List.of(
				SlotText.bottomRight(Text.literal(String.valueOf(attributeLevel)).withColor(0xFFDDC1)),
				SlotText.topLeft(Text.literal(attributeInitials).withColor(0xCFF8F8))
		);
	}

	@Override
	public boolean isEnabled() {
		return SkyblockerConfigManager.get().general.itemInfoDisplay.attributeShardInfo;
	}
}