air-place module

air-place: Minecraft 26.3 cheat module, full source for every implementation (1 client: Meteor Client).

1 implementationPlayer

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.

Meteor ClientPlayersrc/main/java/meteordevelopment/meteorclient/systems/modules/player/AirPlace.javaJava · 132 lines · 5.0 KB

Places a block where your crosshair is pointing at.

Settingsrendershape-modeside-colorline-colorcustom-rangerange
AirPlace.javaJava · Minecraft 26.2 · 132 lines · 5.0 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.player;
7
8
import meteordevelopment.meteorclient.events.entity.player.InteractItemEvent;
9
import meteordevelopment.meteorclient.events.render.Render3DEvent;
10
import meteordevelopment.meteorclient.events.world.TickEvent;
11
import meteordevelopment.meteorclient.renderer.ShapeMode;
12
import meteordevelopment.meteorclient.settings.*;
13
import meteordevelopment.meteorclient.systems.modules.Categories;
14
import meteordevelopment.meteorclient.systems.modules.Module;
15
import meteordevelopment.meteorclient.utils.player.InvUtils;
16
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
17
import meteordevelopment.meteorclient.utils.world.BlockUtils;
18
import meteordevelopment.orbit.EventHandler;
19
import net.minecraft.world.InteractionResult;
20
import net.minecraft.world.item.*;
21
import net.minecraft.world.level.block.Block;
22
import net.minecraft.world.level.block.Blocks;
23
import net.minecraft.world.phys.BlockHitResult;
24
import net.minecraft.world.phys.HitResult;
25
import net.minecraft.world.phys.Vec3;
26
27
public class AirPlace extends Module {
28
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
29
    private final SettingGroup sgRange = settings.createGroup("Range");
30
31
    // General
32
33
    private final Setting<Boolean> render = sgGeneral.add(new BoolSetting.Builder()
34
        .name("render")
35
        .description("Renders a block overlay where the obsidian will be placed.")
36
        .defaultValue(true)
37
        .build()
38
    );
39
40
    private final Setting<ShapeMode> shapeMode = sgGeneral.add(new EnumSetting.Builder<ShapeMode>()
41
        .name("shape-mode")
42
        .description("How the shapes are rendered.")
43
        .defaultValue(ShapeMode.Both)
44
        .build()
45
    );
46
47
    private final Setting<SettingColor> sideColor = sgGeneral.add(new ColorSetting.Builder()
48
        .name("side-color")
49
        .description("The color of the sides of the blocks being rendered.")
50
        .defaultValue(new SettingColor(204, 0, 0, 10))
51
        .build()
52
    );
53
54
    private final Setting<SettingColor> lineColor = sgGeneral.add(new ColorSetting.Builder()
55
        .name("line-color")
56
        .description("The color of the lines of the blocks being rendered.")
57
        .defaultValue(new SettingColor(204, 0, 0, 255))
58
        .build()
59
    );
60
61
    // Range
62
63
    private final Setting<Boolean> customRange = sgRange.add(new BoolSetting.Builder()
64
        .name("custom-range")
65
        .description("Use custom range for air place.")
66
        .defaultValue(false)
67
        .build()
68
    );
69
70
    private final Setting<Double> range = sgRange.add(new DoubleSetting.Builder()
71
        .name("range")
72
        .description("Custom range to place at.")
73
        .visible(customRange::get)
74
        .defaultValue(5)
75
        .min(0)
76
        .sliderMax(6)
77
        .build()
78
    );
79
80
    private HitResult hitResult;
81
82
    public AirPlace() {
83
        super(Categories.Player, "air-place", "Places a block where your crosshair is pointing at.");
84
    }
85
86
    @EventHandler
87
    private void onTick(TickEvent.Pre event) {
88
        if (!InvUtils.testInHands(this::placeable)) return;
89
        if (mc.hitResult != null && mc.hitResult.getType() != HitResult.Type.MISS) return;
90
91
        double r = customRange.get() ? range.get() : mc.player.blockInteractionRange();
92
        hitResult = mc.getCameraEntity().pick(r, 0, false);
93
    }
94
95
    @EventHandler
96
    private void onInteractItem(InteractItemEvent event) {
97
        if (!(hitResult instanceof BlockHitResult bhr) || !placeable(mc.player.getItemInHand(event.hand))) return;
98
99
        Block toPlace = Blocks.OBSIDIAN;
100
        Item i = mc.player.getItemInHand(event.hand).getItem();
101
        if (i instanceof BlockItem blockItem) toPlace = blockItem.getBlock();
102
        if (!BlockUtils.canPlaceBlock(bhr.getBlockPos(), (i instanceof ArmorStandItem || i instanceof BlockItem), toPlace))
103
            return;
104
105
        Vec3 hitPos = Vec3.atCenterOf(bhr.getBlockPos());
106
107
        BlockHitResult b = new BlockHitResult(hitPos, mc.player.getMotionDirection().getOpposite(), bhr.getBlockPos(), false);
108
        BlockUtils.interact(b, event.hand, true);
109
110
        event.toReturn = InteractionResult.SUCCESS;
111
    }
112
113
    @EventHandler
114
    private void onRender(Render3DEvent event) {
115
        if (!(hitResult instanceof BlockHitResult bhr)
116
            || (mc.hitResult != null && mc.hitResult.getType() != HitResult.Type.MISS)
117
            || !mc.level.getBlockState(bhr.getBlockPos()).canBeReplaced()
118
            || !InvUtils.testInHands(this::placeable)
119
            || !render.get()) return;
120
121
        event.renderer.box(bhr.getBlockPos(), sideColor.get(), lineColor.get(), shapeMode.get(), 0);
122
    }
123
124
    private boolean placeable(ItemStack stack) {
125
        Item i = stack.getItem();
126
        return i instanceof BlockItem
127
            || i instanceof SpawnEggItem
128
            || (i instanceof FireworkRocketItem && !mc.player.isFallFlying())
129
            || i instanceof ArmorStandItem;
130
    }
131
}
132