//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.nicside.client.features.modules.combat;
import com.nicside.api.event.III1111Ill;
import com.nicside.api.event.l1Ill11IlI;
import com.nicside.api.event.events.client.I1I1ll11l1;
import com.nicside.api.event.events.client.L1IIlIlIl1;
import com.nicside.api.event.events.player.other.lIlIIIlIll;
import com.nicside.api.module.lI11I1lIII;
import com.nicside.api.module.ll1llIIIIl;
import com.nicside.api.module.llIlI1Illl;
import com.nicside.api.module.setting.I111l1II1l;
import com.nicside.api.module.setting.L11II1IIl1;
import com.nicside.api.module.setting.LI1I1lI111;
import com.nicside.api.utils.other.lllll1llIl;
import com.nicside.api.utils.player.IIlIlI111I;
import com.nicside.client.ui.widget.overlay.ll1llll1II;
import com.nicside.client.ui.widget.overlay.ll1llll1II.lIlIIII1I1;
import lombok.Generated;
import net.minecraft.class_1792;
import net.minecraft.class_1802;
@llIlI1Illl(
name = "Item Swap",
category = lI11I1lIII.COMBAT
)
public class L1Il1IIlII extends ll1llIIIIl {
private static final L1Il1IIlII instance = new L1Il1IIlII();
private final LI1I1lI111 swapKey = (new LI1I1lI111("Swap key")).value(-999);
private final I111l1II1l firstItem = (new I111l1II1l("First item")).value("Shield").values(new String[]{"Shield", "GApple", "Totem", "Ball"});
private final I111l1II1l secondItem = (new I111l1II1l("Second item")).value("GApple").values(new String[]{"Shield", "GApple", "Totem", "Ball"});
private boolean swapping = false;
public L1Il1IIlII() {
this.addSettings(new L11II1IIl1[]{this.swapKey, this.firstItem, this.secondItem});
}
public void onEvent() {
III1111Ill keyEvent = I1I1ll11l1.getInstance().subscribe(new l1Ill11IlI((event) -> {
if (event.key() == (Integer)this.swapKey.getValue() && event.action() == 1 && mc.field_1755 == null) {
this.swapping = true;
}
}));
III1111Ill tickEvent = L1IIlIlIl1.getInstance().subscribe(new l1Ill11IlI((event) -> {
if (lllll1llIl.isEnabled()) {
this.performSwap();
}
}));
III1111Ill updateEvent = lIlIIIlIll.getInstance().subscribe(new l1Ill11IlI((event) -> {
if (!lllll1llIl.isEnabled()) {
this.performSwap();
}
}));
this.addEvents(new III1111Ill[]{keyEvent, tickEvent, updateEvent});
}
private void performSwap() {
if (mc.field_1687 != null && mc.field_1724 != null && mc.field_1761 != null && this.swapping) {
class_1792 item = this.getItem();
if (item == null) {
this.print("Предмет не найден");
this.swapping = false;
} else {
int slot = IIlIlI111I.findItem(item);
if (slot == -1) {
this.print("Предмет не найден в инвентаре");
this.swapping = false;
} else {
if (lllll1llIl.isEnabled()) {
lllll1llIl.applySlowness(10L, () -> this.swap(slot));
} else {
this.swap(slot);
}
}
}
}
}
private class_1792 getItem() {
class_1792 primary = this.getItemByMode((String)this.firstItem.getValue());
class_1792 secondary = this.getItemByMode((String)this.secondItem.getValue());
return mc.field_1724.method_6079().method_7909() == primary ? secondary : primary;
}
private void swap(int slot) {
if (mc.field_1761 != null) {
this.print("Свапнул на \"" + this.getItem().method_63680().getString() + "\"");
ll1llll1II.notify("Свапнул на " + this.getItem().method_63680().getString(), lIlIIII1I1.SUCCESS);
if (lllll1llIl.isEnabled()) {
lllll1llIl.applySlowness(10L, () -> IIlIlI111I.swapToOffhand(slot));
} else {
IIlIlI111I.swapToOffhand(slot);
}
this.swapping = false;
}
}
private class_1792 getItemByMode(String name) {
class_1792 var10000;
switch (name.toLowerCase()) {
case "shield" -> var10000 = class_1802.field_8255;
case "ball" -> var10000 = class_1802.field_8575;
case "totem" -> var10000 = class_1802.field_8288;
case "gapple" -> var10000 = class_1802.field_8463;
default -> var10000 = null;
}
return var10000;
}
@Generated
public static L1Il1IIlII getInstance() {
return instance;
}
}