use of com.tangykiwi.kiwiclient.event.ItemStackTooltipEvent in project KiwiClient by TangyKiwi.
the class Tooltips method appendTooltip.
@Subscribe
@AllowConcurrentEvents
public void appendTooltip(ItemStackTooltipEvent event) {
// Stew
if (getSetting(0).asToggle().state) {
if (event.itemStack.getItem() == Items.SUSPICIOUS_STEW) {
NbtCompound tag = event.itemStack.getNbt();
if (tag != null) {
NbtList effects = tag.getList("Effects", 10);
if (effects != null) {
for (int i = 0; i < effects.size(); i++) {
NbtCompound effectTag = effects.getCompound(i);
byte effectId = effectTag.getByte("EffectId");
int effectDuration = effectTag.contains("EffectDuration") ? effectTag.getInt("EffectDuration") : 160;
StatusEffectInstance effect = new StatusEffectInstance(StatusEffect.byRawId(effectId), effectDuration, 0);
event.list.add(1, getStatusText(effect));
}
}
}
} else if (event.itemStack.getItem().isFood()) {
FoodComponent food = event.itemStack.getItem().getFoodComponent();
if (food != null) {
food.getStatusEffects().forEach((e) -> {
StatusEffectInstance effect = e.getFirst();
event.list.add(1, getStatusText(effect));
});
}
}
}
// Bees
if (getSetting(1).asToggle().state) {
if (event.itemStack.getItem() == Items.BEEHIVE || event.itemStack.getItem() == Items.BEE_NEST) {
NbtCompound tag = event.itemStack.getNbt();
if (tag != null) {
NbtCompound blockStateTag = tag.getCompound("BlockStateTag");
if (blockStateTag != null) {
int level = blockStateTag.getInt("honey_level");
event.list.add(1, new LiteralText(String.format("%sHoney Level: %s%d%s", Formatting.GRAY, Formatting.YELLOW, level, Formatting.GRAY)));
}
NbtCompound blockEntityTag = tag.getCompound("BlockEntityTag");
if (blockEntityTag != null) {
NbtList beesTag = blockEntityTag.getList("Bees", 10);
event.list.add(1, new LiteralText(String.format("%sBees: %s%d%s", Formatting.GRAY, Formatting.YELLOW, beesTag.size(), Formatting.GRAY)));
}
}
}
}
// Fish handled in EntityBucketItemMixin
}
Aggregations