-
Автор темы
- #1
Видел как сливали разные нотифки, по типу HPalert, ArmorAlert, решил сделать под элитры.
| Когда ваш элитра хелпер багается и элики дропаются, то вам об этом сообщат ну типа пон да, полезная функция, знаю |
| Когда ваш элитра хелпер багается и элики дропаются, то вам об этом сообщат ну типа пон да, полезная функция, знаю |
Ватафак:
//by neznakomej1337 ebat ya huetu sdelal
package sosala.Nightly.functions.impl.player;
import com.google.common.eventbus.Subscribe;
import sosala.Nightly.events.EventUpdate;
import sosala.Nightly.functions.api.Category;
import sosala.Nightly.functions.api.Function;
import sosala.Nightly.functions.api.FunctionRegister;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
@FunctionRegister(name = "NotifyElytra", type = Category.Player)
public class NotifyElytra extends Function {
private boolean elytraPresent = true;
@Subscribe
private void onUpdate(EventUpdate eventUpdate) {
int elytraCount = this.countItems(Items.ELYTRA);
elytraCount += this.countItemsInOffhand(Items.ELYTRA);
if (elytraCount == 0 && this.elytraPresent) {
this.print("ElytraNotify: античит выбросил ваши элитры!");
this.elytraPresent = false;
} else if (elytraCount > 0) {
this.elytraPresent = true;
}
boolean hasElytraEquipped = this.hasElytraEquipped();
if (!hasElytraEquipped && this.elytraPresent) {
this.print("ElytraNotify: античит выбросил ваши элитры!");
this.elytraPresent = false;
} else if (hasElytraEquipped) {
this.elytraPresent = true;
}
}
private int countItems(Item item) {
int count = 0;
for (ItemStack itemStack : NotifyElytra.mc.player.inventory.mainInventory) {
if (itemStack.getItem() == item) {
count += itemStack.getCount();
}
}
return count;
}
private int countItemsInOffhand(Item item) {
ItemStack itemStack = NotifyElytra.mc.player.getHeldItemOffhand();
if (itemStack.getItem() == item) {
return itemStack.getCount();
}
return 0;
}
private boolean hasElytraEquipped() {
ItemStack itemStack = NotifyElytra.mc.player.inventory.armorItemInSlot(2);
return !itemStack.isEmpty() && itemStack.getItem() == Items.ELYTRA;
}
}