WorldTweaks module

WorldTweaks: Minecraft 26.3 cheat module, full source for every implementation (2 clients: MelaHack (ThunderHack fork), Combatant).

2 implementationsRENDERVISUALS

Full module source: 2 implementations

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

MelaHack (ThunderHack fork)RENDERsrc/main/java/thunder/hack/features/modules/render/WorldTweaks.javaJava · 57 lines · 2.0 KB
SettingsFogModifyFogStartFogEndFogColorChangeTimeTime
WorldTweaks.javaJava · Minecraft 26.2 · 57 lines · 2.0 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.render;
2
3
import meteordevelopment.orbit.EventHandler;
4
import net.minecraft.network.protocol.game.ClientboundSetTimePacket;
5
import thunder.hack.events.impl.PacketEvent;
6
import thunder.hack.features.modules.Module;
7
import thunder.hack.setting.Setting;
8
import thunder.hack.setting.impl.BooleanSettingGroup;
9
import thunder.hack.setting.impl.ColorSetting;
10
11
import java.awt.*;
12
13
public class WorldTweaks extends Module {
14
    public WorldTweaks() {
15
        super("WorldTweaks", Category.RENDER);
16
    }
17
18
    public static final Setting<BooleanSettingGroup> fogModify = new Setting<>("FogModify", new BooleanSettingGroup(true));
19
    public static final Setting<Integer> fogStart = new Setting<>("FogStart", 0, 0, 256).addToGroup(fogModify);
20
    public static final Setting<Integer> fogEnd = new Setting<>("FogEnd", 64, 10, 256).addToGroup(fogModify);
21
    public static final Setting<ColorSetting> fogColor = new Setting<>("FogColor", new ColorSetting(new Color(0xA900FF))).addToGroup(fogModify);
22
    public final Setting<Boolean> ctime = new Setting<>("ChangeTime", false);
23
    public final Setting<Integer> ctimeVal = new Setting<>("Time", 21, 0, 23);
24
25
    long oldTime;
26
    long oldTimeOfDay;
27
    boolean oldTickDayTime = true;
28
29
    @Override
30
    public void onEnable() {
31
        oldTime = mc.level.getGameTime();
32
        oldTimeOfDay = mc.level.getDefaultClockTime();
33
    }
34
35
    @Override
36
    public void onDisable() {
37
        mc.level.setTimeFromServer(oldTime);
38
    }
39
40
    @EventHandler
41
    private void onPacketReceive(PacketEvent.Receive event) {
42
        if (event.getPacket() instanceof ClientboundSetTimePacket && ctime.getValue()) {
43
            ClientboundSetTimePacket packet = (ClientboundSetTimePacket) event.getPacket();
44
            oldTime = packet.gameTime();
45
            oldTimeOfDay = mc.level.getDefaultClockTime();
46
            oldTickDayTime = true;
47
            event.cancel();
48
        }
49
    }
50
51
    @Override
52
    public void onUpdate() {
53
        if (ctime.getValue())
54
            mc.level.setTimeFromServer(ctimeVal.getValue() * 1000L);
55
    }
56
}
57
CombatantVISUALSsrc/main/java/combatant/client/features/module/modules/visuals/WorldTweaks.javaJava · 361 lines · 13.6 KB
SettingsworldTweaksFogControlworldTweaksFogModifyworldTweaksFogStartworldTweaksFogEndworldTweaksFogColornoFogLiquidsnoFogAtmosphericnoFogDistanceBlocksnoFogWeatherDistanceBlocksworldTweaksWeatherControlweatherModeworldTweaksSkyworldTweaksSkyColorworldTweaksSkyGradientColorworldTweaksChangeTimetimeControlSyncSystemTimeworldTweaksTimeHoursworldTweaksItemPhysics
WorldTweaks.javaJava · Minecraft 26.2 · 361 lines · 13.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.features.module.modules.visuals;
9
10
import combatant.client.config.values.*;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.renderer.fog.FogData;
13
import net.minecraft.client.renderer.state.level.SkyRenderState;
14
import net.minecraft.core.BlockPos;
15
import net.minecraft.network.protocol.game.ClientboundSetTimePacket;
16
import net.minecraft.util.ARGB;
17
import net.minecraft.util.Mth;
18
import net.minecraft.world.level.Level;
19
import net.minecraft.world.level.biome.Biome;
20
import net.minecraft.world.level.levelgen.Heightmap;
21
import combatant.client.config.values.*;
22
import combatant.client.events.EventHandler;
23
import combatant.client.events.impl.GameTickEvent;
24
import combatant.client.events.impl.PacketEvent;
25
import combatant.client.features.module.Module;
26
import combatant.client.features.module.ModuleCategory;
27
import combatant.client.features.module.ModuleInfo;
28
import combatant.client.features.module.WorldPhase;
29
import combatant.client.mixins.accessors.WorldAccessor;
30
import combatant.client.render.engine.RenderState;
31
32
import java.time.LocalTime;
33
import java.util.LinkedHashMap;
34
35
//todo Description
36
@ModuleInfo(id = "worldtweaks", displayName = "WorldTweaks", category = ModuleCategory.VISUALS)
37
public class WorldTweaks extends Module {
38
39
    private static final long DAY_TICKS = 24000L;
40
    private static final float RAIN_THRESHOLD = 0.2f;
41
    private static final float THUNDER_THRESHOLD = 0.9f;
42
43
    private static final String SETTING_FOG_CONTROL = "fog_control";
44
    private static final String SETTING_FOG_MODIFY = "fog_modify";
45
    private static final String SETTING_FOG_START = "fog_start";
46
    private static final String SETTING_FOG_END = "fog_end";
47
    private static final String SETTING_FOG_COLOR = "fog_color";
48
    private static final String SETTING_LIQUID_FOG = "liquid_fog";
49
    private static final String SETTING_ATMOSPHERIC_FOG = "atmospheric_fog";
50
    private static final String SETTING_DISTANCE_BLOCKS = "distance_blocks";
51
    private static final String SETTING_WEATHER_DISTANCE_BLOCKS = "weather_distance_blocks";
52
53
    private static final String SETTING_WEATHER_CONTROL = "weather_control";
54
    private static final String SETTING_WEATHER_MODE = "weather_mode";
55
    private static final String SETTING_SKY = "sky";
56
    private static final String SETTING_SKY_COLOR = "sky_color";
57
    private static final String SETTING_SKY_GRADIENT_COLOR = "sky_gradient_color";
58
59
    private static final String SETTING_CHANGE_TIME = "change_time";
60
    private static final String SETTING_TIME_HOURS = "time_hours";
61
    private static final String SETTING_SYNC_SYSTEM_TIME = "sync_system_time";
62
    private static final String SETTING_ITEM_PHYSICS = "item_physics";
63
    private static volatile long serverTimeOfDay;
64
    private final BooleanValue fogControlEnabled =
65
            bool("worldTweaksFogControl", SETTING_FOG_CONTROL, true);
66
    private final BooleanValue fogModifyEnabled =
67
            visibleWhen(bool("worldTweaksFogModify", SETTING_FOG_MODIFY, false), fogControlEnabled::get);
68
    private final NumberValue<Integer> fogStart =
69
            visibleWhen(num("worldTweaksFogStart", SETTING_FOG_START, 0, 0, 256),
70
                    () -> fogControlEnabled.get() && fogModifyEnabled.get());
71
    private final NumberValue<Integer> fogEnd =
72
            visibleWhen(num("worldTweaksFogEnd", SETTING_FOG_END, 64, 10, 256),
73
                    () -> fogControlEnabled.get() && fogModifyEnabled.get());
74
    private final RGBColorValue fogColor =
75
            visibleWhen(colorNoAlpha("worldTweaksFogColor", SETTING_FOG_COLOR, "#A900FF"),
76
                    () -> fogControlEnabled.get() && fogModifyEnabled.get());
77
    private final BooleanMapValue liquidToggles = visibleWhen(group(
78
            "noFogLiquids",
79
            SETTING_LIQUID_FOG,
80
            new LinkedHashMap<>() {{
81
                put("Water", true);
82
                put("Lava", true);
83
                put("Powder snow", true);
84
            }}
85
    ), fogControlEnabled::get);
86
    private final BooleanMapValue atmosphericToggles = visibleWhen(group(
87
            "noFogAtmospheric",
88
            SETTING_ATMOSPHERIC_FOG,
89
            new LinkedHashMap<>() {{
90
                put("Overworld", true);
91
                put("Nether", true);
92
                put("End", true);
93
                put("Distance fog", true);
94
                put("Weather fog", true);
95
            }}
96
    ), fogControlEnabled::get);
97
    private final NumberValue<Integer> distanceBlocks =
98
            visibleWhen(num("noFogDistanceBlocks", SETTING_DISTANCE_BLOCKS, 1024, 32, 8192),
99
                    () -> fogControlEnabled.get() && atmosphericToggles.get("Distance fog"));
100
    private final NumberValue<Integer> weatherDistanceBlocks =
101
            visibleWhen(num("noFogWeatherDistanceBlocks", SETTING_WEATHER_DISTANCE_BLOCKS, 512, 32, 8192),
102
                    () -> fogControlEnabled.get() && atmosphericToggles.get("Weather fog"));
103
    private final BooleanValue weatherControlEnabled =
104
            bool("worldTweaksWeatherControl", SETTING_WEATHER_CONTROL, false);
105
    private final ModeValue weatherMode =
106
            visibleWhen(modeSetting("weatherMode", SETTING_WEATHER_MODE, "CLEAR", "CLEAR", "RAIN", "THUNDER"),
107
                    weatherControlEnabled::get);
108
    private final BooleanMapValue skyToggles = group(
109
            "worldTweaksSky",
110
            SETTING_SKY,
111
            new LinkedHashMap<>() {{
112
                put("Sky color", false);
113
                put("Sky gradient", false);
114
            }}
115
    );
116
    private final RGBColorValue skyColor =
117
            visibleWhen(colorNoAlpha("worldTweaksSkyColor", SETTING_SKY_COLOR, "#78A7FF"),
118
                    () -> skyToggles.get("Sky color"));
119
    private final RGBColorValue skyGradientColor =
120
            visibleWhen(colorNoAlpha("worldTweaksSkyGradientColor", SETTING_SKY_GRADIENT_COLOR, "#FF8A5B"),
121
                    () -> skyToggles.get("Sky gradient"));
122
    private final BooleanValue changeTime =
123
            bool("worldTweaksChangeTime", SETTING_CHANGE_TIME, false);
124
    private final BooleanValue syncSystemTime =
125
            visibleWhen(bool("timeControlSyncSystemTime", SETTING_SYNC_SYSTEM_TIME, false), changeTime::get);
126
    private final NumberValue<Integer> timeHours =
127
            visibleWhen(num("worldTweaksTimeHours", SETTING_TIME_HOURS, 21, 0, 23),
128
                    () -> changeTime.get() && !syncSystemTime.get());
129
    private final BooleanValue itemPhysicsEnabled =
130
            bool("worldTweaksItemPhysics", SETTING_ITEM_PHYSICS, true);
131
    private boolean wasOverridingTime;
132
133
    private static int getHourTicks(int hour) {
134
        return Math.floorMod(hour - 6, 24) * 1000;
135
    }
136
137
    public static float getWindTimeSeconds() {
138
        Minecraft client = Minecraft.getInstance();
139
        if (client != null && client.level != null) {
140
            long time = client.level.getGameTime() % 24000L;
141
            return (time + RenderState.tickProgress) / 20.0f;
142
        }
143
        long nowMs = System.currentTimeMillis();
144
        return (nowMs % 100000L) / 1000.0f;
145
    }
146
147
    public static long getServerTimeOfDay() {
148
        return serverTimeOfDay;
149
    }
150
151
    public static void setServerTimeOfDay(long value) {
152
        serverTimeOfDay = value;
153
    }
154
155
    public static boolean isServerRaining(Level world) {
156
        return canHaveWeather(world) && getRawRainGradient(world, 1.0f) > RAIN_THRESHOLD;
157
    }
158
159
    public static boolean isServerThundering(Level world) {
160
        return canHaveWeather(world) && getRawThunderGradient(world, 1.0f) > THUNDER_THRESHOLD;
161
    }
162
163
    public static boolean hasServerRainAt(Level world, BlockPos pos) {
164
        if (world == null || pos == null) return false;
165
        if (!isServerRaining(world)) return false;
166
        if (!world.canSeeSky(pos)) return false;
167
        if (world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos).getY() > pos.getY()) return false;
168
        Biome biome = world.getBiome(pos).value();
169
        return biome.getPrecipitationAt(pos, world.getSeaLevel()) == Biome.Precipitation.RAIN;
170
    }
171
172
    private static boolean canHaveWeather(Level world) {
173
        return world != null && world.dimensionType().hasSkyLight() && !world.dimensionType().hasCeiling();
174
    }
175
176
    private static float getRawRainGradient(Level world, float tickDelta) {
177
        if (!(world instanceof WorldAccessor accessor)) return 0.0f;
178
        return Mth.lerp(
179
                tickDelta,
180
                accessor.combatant$getLastRainGradientRaw(),
181
                accessor.combatant$getRainGradientRaw()
182
        );
183
    }
184
185
    private static float getRawThunderGradient(Level world, float tickDelta) {
186
        if (!(world instanceof WorldAccessor accessor)) return 0.0f;
187
        float thunder = Mth.lerp(
188
                tickDelta,
189
                accessor.combatant$getLastThunderGradientRaw(),
190
                accessor.combatant$getThunderGradientRaw()
191
        );
192
        return thunder * getRawRainGradient(world, tickDelta);
193
    }
194
195
    @Override
196
    public WorldPhase getWorldPhase() {
197
        return WorldPhase.BEFORE_TRANSLUCENT;
198
    }
199
200
    @EventHandler(priority = 1000)
201
    private void onPacketReceive(PacketEvent.Receive event) {
202
        if (!(event.getPacket() instanceof ClientboundSetTimePacket packet)) return;
203
        setServerTimeOfDay(packet.gameTime());
204
    }
205
206
    @EventHandler
207
    private void onGameTick(GameTickEvent event) {
208
        boolean overriding = shouldOverrideTime();
209
        if (overriding || wasOverridingTime) {
210
            invalidateEnvironmentAttributes();
211
        }
212
        wasOverridingTime = overriding;
213
    }
214
215
    @Override
216
    public void onDisable() {
217
        wasOverridingTime = false;
218
        invalidateEnvironmentAttributes();
219
    }
220
221
    public boolean shouldOverrideTime() {
222
        return isEnabled() && changeTime.get();
223
    }
224
225
    public boolean isItemPhysicsEnabled() {
226
        return isEnabled() && itemPhysicsEnabled.get();
227
    }
228
229
    public int getTimeOfDayTicks() {
230
        if (syncSystemTime.get()) {
231
            return getSystemTimeTicks();
232
        }
233
        return getHourTicks(Mth.clamp(timeHours.get(), 0, 23));
234
    }
235
236
    public long getRenderClockTicks() {
237
        long dayBase = Math.floorDiv(serverTimeOfDay, DAY_TICKS) * DAY_TICKS;
238
        return dayBase + getTimeOfDayTicks();
239
    }
240
241
    private static void invalidateEnvironmentAttributes() {
242
        Minecraft client = Minecraft.getInstance();
243
        if (client != null && client.level != null) {
244
            client.level.environmentAttributes().invalidateTickCache();
245
        }
246
    }
247
248
    private int getSystemTimeTicks() {
249
        LocalTime now = LocalTime.now();
250
        double seconds = now.toNanoOfDay() / 1_000_000_000.0;
251
        double ticks = (seconds / 86400.0) * 24000.0;
252
        long mcTicks = Math.round(ticks) + 18000L;
253
        return (int) (mcTicks % 24000L);
254
    }
255
256
    public boolean isWeatherControlEnabled() {
257
        return isEnabled() && weatherControlEnabled.get();
258
    }
259
260
    public WeatherMode getWeatherMode() {
261
        if (!isWeatherControlEnabled()) return WeatherMode.CLEAR;
262
        return switch (weatherMode.get().toUpperCase()) {
263
            case "RAIN" -> WeatherMode.RAIN;
264
            case "THUNDER" -> WeatherMode.THUNDER;
265
            default -> WeatherMode.CLEAR;
266
        };
267
    }
268
269
    public void applySkyOverrides(SkyRenderState sky) {
270
        if (sky == null || !isEnabled()) return;
271
272
        if (skyToggles.get("Sky color")) {
273
            sky.skyColor = ARGB.color(ARGB.alpha(sky.skyColor), skyColor.getArgb());
274
        }
275
276
        if (skyToggles.get("Sky gradient")) {
277
            sky.sunriseAndSunsetColor = ARGB.color(ARGB.alpha(sky.sunriseAndSunsetColor), skyGradientColor.getArgb());
278
        }
279
    }
280
281
    public boolean isFogControlEnabled() {
282
        return isEnabled() && fogControlEnabled.get();
283
    }
284
285
    public boolean isFogModifyEnabled() {
286
        return isFogControlEnabled() && fogModifyEnabled.get();
287
    }
288
289
    public int getFogStartBlocks() {
290
        return fogStart.get();
291
    }
292
293
    public int getFogEndBlocks() {
294
        return fogEnd.get();
295
    }
296
297
    public int getFogColorArgb() {
298
        return fogColor.getArgb();
299
    }
300
301
    public void applyFogOverride(FogData data) {
302
        if (data == null) return;
303
        float start = Math.max(0f, fogStart.get());
304
        float end = Math.max(start + 1f, fogEnd.get());
305
306
        data.environmentalStart = start;
307
        data.environmentalEnd = end;
308
        data.renderDistanceStart = start;
309
        data.renderDistanceEnd = end;
310
        data.skyEnd = end;
311
        data.cloudEnd = end;
312
    }
313
314
    public boolean disableWaterFog() {
315
        return isFogControlEnabled() && liquidToggles.get("Water");
316
    }
317
318
    public boolean disableLavaFog() {
319
        return isFogControlEnabled() && liquidToggles.get("Lava");
320
    }
321
322
    public boolean disablePowderSnowFog() {
323
        return isFogControlEnabled() && liquidToggles.get("Powder snow");
324
    }
325
326
    public boolean disableOverworldFog() {
327
        return isFogControlEnabled() && atmosphericToggles.get("Overworld");
328
    }
329
330
    public boolean disableNetherFog() {
331
        return isFogControlEnabled() && atmosphericToggles.get("Nether");
332
    }
333
334
    public boolean disableEndFog() {
335
        return isFogControlEnabled() && atmosphericToggles.get("End");
336
    }
337
338
    public boolean disableDistanceFog() {
339
        return isFogControlEnabled() && atmosphericToggles.get("Distance fog");
340
    }
341
342
    public boolean disableWeatherFog() {
343
        return isFogControlEnabled() && atmosphericToggles.get("Weather fog");
344
    }
345
346
    public int getDistanceBlocks() {
347
        return distanceBlocks.get();
348
    }
349
350
    public int getWeatherDistanceBlocks() {
351
        return weatherDistanceBlocks.get();
352
    }
353
354
    public enum WeatherMode {
355
        CLEAR,
356
        RAIN,
357
        THUNDER
358
    }
359
360
}
361