flamethrower module

flamethrower: Minecraft 26.3 cheat module, full source for every implementation (2 clients: Meteor Client, OfflineClient).

2 implementationsWorldWORLD

Clients with this module

Full module source: 2 implementations

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

Meteor ClientWorldsrc/main/java/meteordevelopment/meteorclient/systems/modules/world/Flamethrower.javaJava · 152 lines · 5.8 KB

Ignites every alive piece of food.

Settingsdistanceanti-breakput-out-firetarget-babiestick-intervalrotateentities
Flamethrower.javaJava · Minecraft 26.2 · 152 lines · 5.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
3
 * Copyright (c) Meteor Development.
4
 */
5
6
package meteordevelopment.meteorclient.systems.modules.world;
7
8
import meteordevelopment.meteorclient.events.world.TickEvent;
9
import meteordevelopment.meteorclient.settings.*;
10
import meteordevelopment.meteorclient.systems.modules.Categories;
11
import meteordevelopment.meteorclient.systems.modules.Module;
12
import meteordevelopment.meteorclient.utils.misc.HorizontalDirection;
13
import meteordevelopment.meteorclient.utils.player.FindItemResult;
14
import meteordevelopment.meteorclient.utils.player.InvUtils;
15
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
16
import meteordevelopment.meteorclient.utils.player.Rotations;
17
import meteordevelopment.orbit.EventHandler;
18
import net.minecraft.core.Direction;
19
import net.minecraft.world.InteractionHand;
20
import net.minecraft.world.entity.Entity;
21
import net.minecraft.world.entity.EntityType;
22
import net.minecraft.world.entity.EntityTypes;
23
import net.minecraft.world.entity.LivingEntity;
24
import net.minecraft.world.item.Items;
25
import net.minecraft.world.level.block.Block;
26
import net.minecraft.world.level.block.Blocks;
27
import net.minecraft.world.phys.BlockHitResult;
28
import net.minecraft.world.phys.Vec3;
29
30
import java.util.Set;
31
32
public class Flamethrower extends Module {
33
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
34
35
    private final Setting<Double> distance = sgGeneral.add(new DoubleSetting.Builder()
36
        .name("distance")
37
        .description("The maximum distance the animal has to be to be roasted.")
38
        .min(0.0)
39
        .defaultValue(5.0)
40
        .build()
41
    );
42
43
    private final Setting<Boolean> antiBreak = sgGeneral.add(new BoolSetting.Builder()
44
        .name("anti-break")
45
        .description("Prevents flint and steel from being broken.")
46
        .defaultValue(false)
47
        .build()
48
    );
49
50
    private final Setting<Boolean> putOutFire = sgGeneral.add(new BoolSetting.Builder()
51
        .name("put-out-fire")
52
        .description("Tries to put out the fire when animal is low health, so the items don't burn.")
53
        .defaultValue(true)
54
        .build()
55
    );
56
57
    private final Setting<Boolean> targetBabies = sgGeneral.add(new BoolSetting.Builder()
58
        .name("target-babies")
59
        .description("If checked babies will also be killed.")
60
        .defaultValue(false)
61
        .build()
62
    );
63
64
    private final Setting<Integer> tickInterval = sgGeneral.add(new IntSetting.Builder()
65
        .name("tick-interval")
66
        .defaultValue(5)
67
        .build()
68
    );
69
70
    private final Setting<Boolean> rotate = sgGeneral.add(new BoolSetting.Builder()
71
        .name("rotate")
72
        .description("Automatically faces towards the animal roasted.")
73
        .defaultValue(true)
74
        .build()
75
    );
76
77
    private final Setting<Set<EntityType<?>>> entities = sgGeneral.add(new EntityTypeListSetting.Builder()
78
        .name("entities")
79
        .description("Entities to cook.")
80
        .defaultValue(
81
            EntityTypes.PIG,
82
            EntityTypes.COW,
83
            EntityTypes.SHEEP,
84
            EntityTypes.CHICKEN,
85
            EntityTypes.RABBIT
86
        )
87
        .build()
88
    );
89
90
    private Entity entity;
91
    private int ticks = 0;
92
    private InteractionHand hand;
93
94
    public Flamethrower() {
95
        super(Categories.World, "flamethrower", "Ignites every alive piece of food.");
96
    }
97
98
    @Override
99
    public void onDeactivate() {
100
        entity = null;
101
    }
102
103
    @EventHandler
104
    private void onTick(TickEvent.Pre event) {
105
        entity = null;
106
        ticks++;
107
        for (Entity entity : mc.level.entitiesForRendering()) {
108
            if (!entities.get().contains(entity.getType()) || !PlayerUtils.isWithin(entity, distance.get())) continue;
109
            if (entity == mc.player) continue;
110
            if (!entity.isAlive() || entity.isInPowderSnow || entity.isInWaterOrRain() || entity.fireImmune())
111
                continue;
112
113
            if (!targetBabies.get() && entity instanceof LivingEntity livingEntity && livingEntity.isBaby()) continue;
114
115
            FindItemResult item = InvUtils.findInHotbar(itemStack -> (itemStack.is(Items.FLINT_AND_STEEL) || itemStack.is(Items.FIRE_CHARGE)) &&
116
                (!itemStack.isDamageableItem() || !antiBreak.get() || itemStack.getDamageValue() < itemStack.getMaxDamage() - 1));
117
            if (!InvUtils.swap(item.slot(), true)) return;
118
119
            this.hand = item.getHand();
120
            this.entity = entity;
121
122
            if (rotate.get())
123
                Rotations.rotate(Rotations.getYaw(entity.blockPosition()), Rotations.getPitch(entity.blockPosition()), -100, this::interact);
124
            else interact();
125
126
            return;
127
        }
128
    }
129
130
    private void interact() {
131
        Block block = mc.level.getBlockState(entity.blockPosition()).getBlock();
132
        Block bottom = mc.level.getBlockState(entity.blockPosition().below()).getBlock();
133
        if (block == Blocks.WATER || bottom == Blocks.WATER || bottom == Blocks.DIRT_PATH) return;
134
        if (block == Blocks.GRASS_BLOCK) mc.gameMode.startDestroyBlock(entity.blockPosition(), Direction.DOWN);
135
136
        if (putOutFire.get() && entity instanceof LivingEntity animal && animal.getHealth() < 2) {
137
            mc.gameMode.startDestroyBlock(entity.blockPosition(), Direction.DOWN);
138
            for (HorizontalDirection direction : HorizontalDirection.values()) {
139
                mc.gameMode.startDestroyBlock(entity.blockPosition().offset(direction.offsetX, 0, direction.offsetZ), Direction.DOWN);
140
            }
141
        } else {
142
            if (ticks >= tickInterval.get() && !entity.isOnFire()) {
143
                mc.gameMode.useItemOn(mc.player, hand, new BlockHitResult(
144
                    entity.position().subtract(new Vec3(0, 1, 0)), Direction.UP, entity.blockPosition().below(), false));
145
                ticks = 0;
146
            }
147
        }
148
149
        InvUtils.swapBack();
150
    }
151
}
152
OfflineClientWORLDsrc/main/java/com/jellypudding/offlineclient/modules/world/Flamethrower.javaJava · 158 lines · 6.2 KB

Sets fire to the animals around you so they drop cooked meat.

SettingsEntitiesRangeIntervalBabiesAnti breakSave dropsRotate
Flamethrower.javaJava · Minecraft 26.2 · 158 lines · 6.2 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.setting.RegistryListSetting;
10
import com.jellypudding.offlineclient.util.BlockUtil;
11
import com.jellypudding.offlineclient.util.EntityUtil;
12
import com.jellypudding.offlineclient.util.InventoryUtil;
13
import com.jellypudding.offlineclient.util.InventoryUtil.SlotSwap;
14
import com.jellypudding.offlineclient.util.ItemUtil;
15
import net.minecraft.core.BlockPos;
16
import net.minecraft.core.Direction;
17
import net.minecraft.core.registries.BuiltInRegistries;
18
import net.minecraft.world.InteractionHand;
19
import net.minecraft.world.entity.Entity;
20
import net.minecraft.world.entity.EntityType;
21
import net.minecraft.world.entity.EntityTypes;
22
import net.minecraft.world.entity.LivingEntity;
23
import net.minecraft.world.item.Items;
24
import net.minecraft.world.level.block.Blocks;
25
import net.minecraft.world.level.block.state.BlockState;
26
import net.minecraft.world.phys.BlockHitResult;
27
import net.minecraft.world.phys.Vec3;
28
29
import java.util.List;
30
31
// Sets fire to the food walking about. It drops cooked.
32
public final class Flamethrower extends Module {
33
34
    // Health at which the drops would burn up with the animal.
35
    private static final float SAVE_DROPS_HEALTH = 2;
36
37
    private final RegistryListSetting<EntityType<?>> entities = new RegistryListSetting<>("Entities",
38
        "Which animals to roast. Click to pick them.", BuiltInRegistries.ENTITY_TYPE,
39
        List.of(EntityTypes.PIG, EntityTypes.COW, EntityTypes.SHEEP,
40
            EntityTypes.CHICKEN, EntityTypes.RABBIT));
41
    private final NumberSetting range = new NumberSetting("Range",
42
        "How close an animal has to be.", 5, 1, 6, 0.1).min(1).max(6);
43
    private final NumberSetting interval = new NumberSetting("Interval",
44
        "Ticks between one light and the next.", 5, 1, 20, 1, " ticks").min(1);
45
    private final BoolSetting babies = new BoolSetting("Babies",
46
        "Also sets fire to young animals.", false);
47
    private final BoolSetting antiBreak = new BoolSetting("Anti break",
48
        "Leaves a flint and steel that is about to snap alone.", false);
49
    private final BoolSetting saveDrops = new BoolSetting("Save drops",
50
        "Puts the fire out once the animal is nearly dead so the meat survives.", true);
51
    private final BoolSetting rotate = new BoolSetting("Rotate",
52
        "Turn towards the animal on the server side.", true);
53
54
    private final SlotSwap slots = new SlotSwap();
55
    private int ticks;
56
    private int burnt;
57
58
    public Flamethrower() {
59
        super("Flamethrower", "Sets fire to the animals around you so they drop cooked meat.", Category.WORLD);
60
        addSettings(entities, range, interval, babies, antiBreak, saveDrops, rotate);
61
        searchTags("cook", "flint and steel", "burn", "roast");
62
    }
63
64
    @Override
65
    public String getSuffix() {
66
        return count(burnt);
67
    }
68
69
    @Override
70
    protected void onEnable() {
71
        ticks = 0;
72
        burnt = 0;
73
    }
74
75
    @Override
76
    protected void onDisable() {
77
        slots.restoreIfMine();
78
    }
79
80
    @Subscribe
81
    private void onTick(TickEvent event) {
82
        if (!inGame() || mc.player.isSpectator()) {
83
            return;
84
        }
85
        ticks++;
86
        Entity target = EntityUtil.nearest(range.getValue(), this::wanted);
87
        if (target == null) {
88
            slots.restoreIfMine();
89
            return;
90
        }
91
        BlockPos feet = target.blockPosition();
92
        BlockPos below = feet.below();
93
        BlockState standing = BlockUtil.state(feet);
94
        BlockState floor = BlockUtil.state(below);
95
        // Fire never takes on wet ground or on a worn path.
96
        if (!standing.getFluidState().isEmpty() || !floor.getFluidState().isEmpty()
97
            || floor.is(Blocks.DIRT_PATH)) {
98
            slots.restoreIfMine();
99
            return;
100
        }
101
        if (rotate.isOn()) {
102
            BlockUtil.faceVector(Vec3.atCenterOf(below));
103
        }
104
        if (saveDrops.isOn() && target instanceof LivingEntity living
105
            && living.getHealth() < SAVE_DROPS_HEALTH) {
106
            putOut(feet);
107
            slots.restoreIfMine();
108
            return;
109
        }
110
        // Tall grass in the way has to come out before the fire will sit there.
111
        if (standing.is(Blocks.SHORT_GRASS) || standing.is(Blocks.TALL_GRASS)) {
112
            mc.gameMode.startDestroyBlock(feet, Direction.DOWN);
113
        }
114
        if (ticks < interval.getInt() || target.isOnFire()) {
115
            slots.restoreIfMine();
116
            return;
117
        }
118
        light(below);
119
    }
120
121
    private void light(BlockPos below) {
122
        int slot = InventoryUtil.hotbarSlot(stack ->
123
            (stack.is(Items.FLINT_AND_STEEL) || stack.is(Items.FIRE_CHARGE))
124
                && (!antiBreak.isOn() || !ItemUtil.nearlyBroken(stack)));
125
        if (slot == -1) {
126
            slots.restoreIfMine();
127
            return;
128
        }
129
        slots.select(slot);
130
        BlockHitResult hit = new BlockHitResult(
131
            Vec3.atCenterOf(below).add(0, 0.5, 0), Direction.UP, below, false);
132
        if (mc.gameMode.useItemOn(mc.player, InteractionHand.MAIN_HAND, hit).consumesAction()) {
133
            mc.player.swing(InteractionHand.MAIN_HAND);
134
            burnt++;
135
        }
136
        ticks = 0;
137
        slots.restoreIfMine();
138
    }
139
140
    // Punching the fire out beats waiting for the animal to burn its own drops.
141
    private void putOut(BlockPos feet) {
142
        mc.gameMode.startDestroyBlock(feet, Direction.DOWN);
143
        for (Direction side : Direction.Plane.HORIZONTAL) {
144
            mc.gameMode.startDestroyBlock(feet.relative(side), Direction.DOWN);
145
        }
146
    }
147
148
    private boolean wanted(Entity entity) {
149
        if (!entities.contains(entity.getType()) || !entity.isAlive()) {
150
            return false;
151
        }
152
        if (entity.isInPowderSnow || entity.isInWaterOrRain() || entity.fireImmune()) {
153
            return false;
154
        }
155
        return babies.isOn() || !(entity instanceof LivingEntity living) || !living.isBaby();
156
    }
157
}
158