| 1 | package thunder.hack.features.modules.player;
|
| 2 |
|
| 3 | import net.minecraft.world.entity.EquipmentSlot;
|
| 4 | import net.minecraft.world.inventory.ContainerInput;
|
| 5 | import net.minecraft.world.item.Items;
|
| 6 | import thunder.hack.features.modules.Module;
|
| 7 | import thunder.hack.utility.Timer;
|
| 8 |
|
| 9 | public class MouseElytraFix extends Module {
|
| 10 | public MouseElytraFix() {
|
| 11 | super("MouseElytraFix", Category.PLAYER);
|
| 12 | }
|
| 13 |
|
| 14 | private final Timer delay = new Timer();
|
| 15 |
|
| 16 | @Override
|
| 17 | public void onUpdate() {
|
| 18 | if (mc.player.getEquipmentSlotForItem(mc.player.containerMenu.getCarried()).isArmor() && !ElytraSwap.swapping) {
|
| 19 | if (delay.every(300) && mc.player.getEquipmentSlotForItem(mc.player.containerMenu.getCarried()) == EquipmentSlot.CHEST)
|
| 20 | if (mc.player.getItemBySlot(EquipmentSlot.CHEST).getItem() == Items.ELYTRA) {
|
| 21 | mc.gameMode.handleContainerInput(0, 6, 1, ContainerInput.PICKUP, mc.player);
|
| 22 | int empty = findEmptySlot();
|
| 23 | boolean needDrop = (empty == 999);
|
| 24 | if (needDrop)
|
| 25 | empty = 9;
|
| 26 | mc.gameMode.handleContainerInput(0, empty, 1, ContainerInput.PICKUP, mc.player);
|
| 27 | if (needDrop)
|
| 28 | mc.gameMode.handleContainerInput(0, -999, 1, ContainerInput.PICKUP, mc.player);
|
| 29 | }
|
| 30 | }
|
| 31 | }
|
| 32 |
|
| 33 | public static int findEmptySlot() {
|
| 34 | for (int i = 0; i < 36; i++)
|
| 35 | if (mc.player.getInventory().getItem(i).isEmpty()) return i < 9 ? i + 36 : i;
|
| 36 | return 999;
|
| 37 | }
|
| 38 | }
|
| 39 |
|