Search in sources :

Example 1 with AbstractDonkeyEntity

use of net.minecraft.entity.passive.AbstractDonkeyEntity in project Client by MatHax.

the class AutoMountBypassDupe method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_ESCAPE) == GLFW.GLFW_PRESS) {
        toggle();
        mc.player.closeHandledScreen();
        return;
    }
    if (timer <= 0)
        timer = delay.get();
    else {
        timer--;
        return;
    }
    int slots = getInvSize(mc.player.getVehicle());
    for (Entity e : mc.world.getEntities()) {
        if (e.distanceTo(mc.player) < 5 && e instanceof AbstractDonkeyEntity && ((AbstractDonkeyEntity) e).isTame())
            entity = (AbstractDonkeyEntity) e;
    }
    if (entity == null)
        return;
    if (sneak) {
        mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY));
        mc.player.setSneaking(false);
        sneak = false;
        return;
    }
    if (slots == -1) {
        if (entity.hasChest() || mc.player.getMainHandStack().getItem() == Items.CHEST) {
            mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.interact(entity, mc.player.isSneaking(), Hand.MAIN_HAND));
        } else {
            int slot = InvUtils.findInHotbar(Items.CHEST).slot();
            if (!InvUtils.swap(slot, true)) {
                error("Cannot find chest in your hotbar, disabling...");
                toggle();
            }
        }
    } else if (slots == 0) {
        if (isDupeTime()) {
            if (!slotsToThrow.isEmpty()) {
                if (faceDown.get())
                    Rotations.rotate(mc.player.getYaw(), 90, 99, this::drop);
                else
                    drop();
            } else {
                for (int i = 2; i < getDupeSize() + 1; i++) {
                    slotsToThrow.add(i);
                }
            }
        } else {
            mc.player.closeHandledScreen();
            mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY));
            mc.player.setSneaking(true);
            sneak = true;
        }
    } else if (!(mc.currentScreen instanceof HorseScreen))
        mc.player.openRidingInventory();
    else if (slots > 0) {
        if (slotsToMove.isEmpty()) {
            boolean empty = true;
            for (int i = 2; i <= slots; i++) {
                if (!(mc.player.currentScreenHandler.getStacks().get(i).isEmpty())) {
                    empty = false;
                    break;
                }
            }
            if (empty) {
                for (int i = slots + 2; i < mc.player.currentScreenHandler.getStacks().size(); i++) {
                    if (!(mc.player.currentScreenHandler.getStacks().get(i).isEmpty())) {
                        if (mc.player.currentScreenHandler.getSlot(i).getStack().getItem() == Items.CHEST)
                            continue;
                        if (!(mc.player.currentScreenHandler.getSlot(i).getStack().getItem() instanceof BlockItem && ((BlockItem) mc.player.currentScreenHandler.getSlot(i).getStack().getItem()).getBlock() instanceof ShulkerBoxBlock) && shulkersOnly.get())
                            continue;
                        slotsToMove.add(i);
                        if (slotsToMove.size() >= slots)
                            break;
                    }
                }
            } else {
                noCancel = true;
                mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.interact(entity, mc.player.isSneaking(), Hand.MAIN_HAND));
                noCancel = false;
                return;
            }
        }
        if (!slotsToMove.isEmpty()) {
            for (int i : slotsToMove) {
                InvUtils.quickMove().from(i).to(0);
            }
            slotsToMove.clear();
        }
    }
}
Also used : AbstractDonkeyEntity(net.minecraft.entity.passive.AbstractDonkeyEntity) Entity(net.minecraft.entity.Entity) LlamaEntity(net.minecraft.entity.passive.LlamaEntity) HorseScreen(net.minecraft.client.gui.screen.ingame.HorseScreen) ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) AbstractDonkeyEntity(net.minecraft.entity.passive.AbstractDonkeyEntity) BlockItem(net.minecraft.item.BlockItem) EventHandler(mathax.client.eventbus.EventHandler)

Aggregations

EventHandler (mathax.client.eventbus.EventHandler)1 ShulkerBoxBlock (net.minecraft.block.ShulkerBoxBlock)1 HorseScreen (net.minecraft.client.gui.screen.ingame.HorseScreen)1 Entity (net.minecraft.entity.Entity)1 AbstractDonkeyEntity (net.minecraft.entity.passive.AbstractDonkeyEntity)1 LlamaEntity (net.minecraft.entity.passive.LlamaEntity)1 BlockItem (net.minecraft.item.BlockItem)1 ClientCommandC2SPacket (net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket)1