Skip to content

Commit

Permalink
Make chest swap close inventory because anticheats
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsupermanhd committed Dec 2, 2023
1 parent 4796623 commit 67480a3
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.item.ArmorItem;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket;

public class ChestSwap extends Module {
private final SettingGroup sgGeneral = settings.getDefaultGroup();
Expand All @@ -35,6 +36,13 @@ public class ChestSwap extends Module {
.build()
);

private final Setting<Boolean> closeInventory = sgGeneral.add(new BoolSetting.Builder()
.name("close-inventory")
.description("Sends inventory close after swap.")
.defaultValue(false)
.build()
);

public ChestSwap() {
super(Categories.Player, "chest-swap", "Automatically swaps between a chestplate and an elytra.");
}
Expand Down Expand Up @@ -120,6 +128,13 @@ private void equipElytra() {

private void equip(int slot) {
InvUtils.move().from(slot).toArmor(2);
if (closeInventory.get()) {
// Notchian clients send a Close Window packet with Window ID 0 to close their inventory even though there is never an Open Screen packet for the inventory.
var n = mc.getNetworkHandler();
if (n != null) {
n.sendPacket(new CloseHandledScreenC2SPacket(0));
}
}
}

@Override
Expand Down

0 comments on commit 67480a3

Please sign in to comment.