AutoShearer module

AutoShearer: Minecraft 26.3 cheat module, full source for every implementation (1 client: OfflineClient).

1 implementationWORLD

Clients with this module

Full module source: 1 implementation

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

OfflineClientWORLDsrc/main/java/com/jellypudding/offlineclient/modules/world/AutoShearer.javaJava · 85 lines · 3.1 KB

Shears every sheep that comes near you.

SettingsRangeAnti breakRotate
AutoShearer.javaJava · Minecraft 26.2 · 85 lines · 3.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.world;
2
3
import com.jellypudding.offlineclient.event.Subscribe;
4
import com.jellypudding.offlineclient.event.events.TickEvent;
5
import com.jellypudding.offlineclient.module.Category;
6
import com.jellypudding.offlineclient.module.Module;
7
import com.jellypudding.offlineclient.setting.BoolSetting;
8
import com.jellypudding.offlineclient.setting.NumberSetting;
9
import com.jellypudding.offlineclient.util.BlockUtil;
10
import com.jellypudding.offlineclient.util.EntityUtil;
11
import com.jellypudding.offlineclient.util.InventoryUtil;
12
import com.jellypudding.offlineclient.util.InventoryUtil.SlotSwap;
13
import com.jellypudding.offlineclient.util.ItemUtil;
14
import net.minecraft.world.InteractionHand;
15
import net.minecraft.world.entity.Entity;
16
import net.minecraft.world.entity.Shearable;
17
import net.minecraft.world.item.Items;
18
import net.minecraft.world.phys.EntityHitResult;
19
20
// Sheep and anything else that takes shears is clipped as it wanders past.
21
public final class AutoShearer extends Module {
22
23
    private final NumberSetting range = new NumberSetting("Range",
24
        "How close an animal has to be.", 5, 1, 6, 0.1).max(6);
25
    private final BoolSetting antiBreak = new BoolSetting("Anti break",
26
        "Never uses shears that are about to break.", true);
27
    private final BoolSetting rotate = new BoolSetting("Rotate",
28
        "Turn towards the animal on the server side.", true);
29
30
    private final SlotSwap slots = new SlotSwap();
31
    private int sheared;
32
33
    public AutoShearer() {
34
        super("AutoShearer", "Shears every sheep that comes near you.", Category.WORLD);
35
        addSettings(range, antiBreak, rotate);
36
        searchTags("sheep", "wool", "shears");
37
    }
38
39
    @Override
40
    public String getSuffix() {
41
        return sheared == 0 ? null : sheared + " sheared";
42
    }
43
44
    @Override
45
    protected void onEnable() {
46
        sheared = 0;
47
    }
48
49
    @Override
50
    protected void onDisable() {
51
        slots.restoreIfMine();
52
    }
53
54
    @Subscribe
55
    private void onTick(TickEvent event) {
56
        if (!inGame() || mc.player.isSpectator() || mc.gui.screen() != null) {
57
            return;
58
        }
59
        Entity target = EntityUtil.nearest(range.getValue(), AutoShearer::ready);
60
        if (target == null) {
61
            slots.restoreIfMine();
62
            return;
63
        }
64
        int slot = InventoryUtil.hotbarSlot(stack ->
65
            stack.is(Items.SHEARS) && (!antiBreak.isOn() || !ItemUtil.nearlyBroken(stack)));
66
        if (slot == -1) {
67
            return;
68
        }
69
        slots.select(slot);
70
        if (rotate.isOn()) {
71
            BlockUtil.faceVector(target.getBoundingBox().getCenter());
72
        }
73
        EntityHitResult hit = new EntityHitResult(target, target.getBoundingBox().getCenter());
74
        if (mc.gameMode.interact(mc.player, target, hit, InteractionHand.MAIN_HAND).consumesAction()) {
75
            mc.player.swing(InteractionHand.MAIN_HAND);
76
            sheared++;
77
        }
78
        slots.restoreIfMine();
79
    }
80
81
    private static boolean ready(Entity entity) {
82
        return entity instanceof Shearable shearable && entity.isAlive() && shearable.readyForShearing();
83
    }
84
}
85