Skip to content

Commit

Permalink
Merge branch 'v7.46.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Oct 30, 2024
2 parents 49cbe62 + 686877e commit 9c5dc1f
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 10 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ org.gradle.parallel=true
# https://modrinth.com/mod/fabric-api/versions
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.7
loader_version=0.16.9

# Fabric API
fabric_version=0.106.1+1.21.3
fabric_version=0.107.0+1.21.3

# Mod Properties
mod_version = v7.46.1-MC1.21.3
mod_version = v7.46.2-MC1.21.3
maven_group = net.wurstclient
archives_base_name = Wurst-Client

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/wurstclient/WurstClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public enum WurstClient
public static MinecraftClient MC;
public static IMinecraftClient IMC;

public static final String VERSION = "7.46.1";
public static final String VERSION = "7.46.2";
public static final String MC_VERSION = "1.21.3";

private WurstAnalytics analytics;
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/net/wurstclient/hacks/MobSpawnEspHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import net.wurstclient.events.RenderListener;
import net.wurstclient.events.UpdateListener;
import net.wurstclient.hack.Hack;
import net.wurstclient.hacks.mobspawnesp.HitboxCheckSetting;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.ChunkAreaSetting;
import net.wurstclient.settings.ChunkAreaSetting.ChunkArea;
Expand Down Expand Up @@ -68,6 +69,8 @@ public final class MobSpawnEspHack extends Hack
private final CheckboxSetting depthTest =
new CheckboxSetting("Depth test", true);

private final HitboxCheckSetting hitboxCheck = new HitboxCheckSetting();

private final ChunkVertexBufferCoordinator coordinator =
new ChunkVertexBufferCoordinator(this::isSpawnable, this::buildBuffer,
drawDistance);
Expand All @@ -84,6 +87,7 @@ public MobSpawnEspHack()
addSetting(dayColor);
addSetting(opacity);
addSetting(depthTest);
addSetting(hitboxCheck);
}

@Override
Expand Down Expand Up @@ -167,11 +171,9 @@ private boolean isSpawnable(BlockPos pos, BlockState state)
if(!SpawnRestriction.isSpawnPosAllowed(EntityType.CREEPER, MC.world,
pos))
return false;

// Check for hitbox collisions
// (using a creeper because it's shorter than a zombie)
if(!MC.world.isSpaceEmpty(EntityType.CREEPER
.getSpawnBox(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5)))
if(!hitboxCheck.isSpaceEmpty(pos))
return false;

// Check block light level
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2014-2024 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.hacks.mobspawnesp;

import java.util.function.Function;

import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.EntityType;
import net.minecraft.util.math.BlockPos;
import net.wurstclient.WurstClient;
import net.wurstclient.settings.EnumSetting;
import net.wurstclient.util.text.WText;

public final class HitboxCheckSetting
extends EnumSetting<HitboxCheckSetting.HitboxCheck>
{
private static final MinecraftClient MC = WurstClient.MC;
private static final WText DESCRIPTION =
WText.translated("description.wurst.setting.mobspawnesp.hitbox_check")
.append(buildDescriptionSuffix());

public HitboxCheckSetting()
{
super("Hitbox check", DESCRIPTION, HitboxCheck.values(),
HitboxCheck.OFF);
}

public boolean isSpaceEmpty(BlockPos pos)
{
return getSelected().check.apply(pos);
}

private static synchronized boolean slowHitboxCheck(BlockPos pos)
{
return unstableHitboxCheck(pos);
}

// "unstable" because isSpaceEmpty() is not thread-safe
private static boolean unstableHitboxCheck(BlockPos pos)
{
return MC.world.isSpaceEmpty(EntityType.CREEPER
.getSpawnBox(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5));
}

private static WText buildDescriptionSuffix()
{
WText text = WText.literal("\n\n");
HitboxCheck[] values = HitboxCheck.values();

for(HitboxCheck value : values)
text.append("\u00a7l" + value.name + "\u00a7r - ")
.append(value.description).append("\n\n");

return text;
}

public enum HitboxCheck
{
OFF("Off", pos -> true),
SLOW("Slow", HitboxCheckSetting::slowHitboxCheck),
UNSTABLE("Unstable", HitboxCheckSetting::unstableHitboxCheck);

private static final String TRANSLATION_KEY_PREFIX =
"description.wurst.setting.mobspawnesp.hitbox_check.";

private final String name;
private final WText description;
private final Function<BlockPos, Boolean> check;

private HitboxCheck(String name, Function<BlockPos, Boolean> check)
{
this.name = name;
description =
WText.translated(TRANSLATION_KEY_PREFIX + name().toLowerCase());
this.check = check;
}

@Override
public String toString()
{
return name;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ protected void onRender(DrawContext context, int mouseX, int mouseY,
featureY);
}

// CURSED: disableScissor() causes weird artifacts if you don't draw
// some text after it.
RenderUtils.disableScissor(context);
context.drawText(textRenderer, ".", -100, -100, 0xFFFFFF, false);

// tooltip
if(tooltip != null)
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/net/wurstclient/util/RenderUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ public static void enableScissor(DrawContext context, int x1, int y1,
}

/**
* Disables the current scissor box, while avoiding the strange side-effects
* of Minecraft's own disableScissor() method.
* Disables the current scissor box, while avoiding most of the strange
* side-effects of Minecraft's own disableScissor() method.
*
* <p>
* <b>Note:</b> You have to draw some text after calling this method,
* otherwise there will be some weird colors in the sky. It's unclear why
* this happens.
*/
public static void disableScissor(DrawContext context)
{
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/wurst/translations/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@
"description.wurst.hack.mileycyrus": "Makes you twerk.",
"description.wurst.hack.mobesp": "Highlights nearby mobs.",
"description.wurst.hack.mobspawnesp": "Highlights areas where mobs can spawn.",
"description.wurst.setting.mobspawnesp.hitbox_check": "Makes MobSpawnESP more accurate by ignoring dark spots that are too small for any mobs to spawn, but can also negatively affect performance and/or stability.",
"description.wurst.setting.mobspawnesp.hitbox_check.off": "No hitbox check.",
"description.wurst.setting.mobspawnesp.hitbox_check.slow": "Synchronized hitbox check. Shouldn't cause any crashes, but has a large impact on game performance.",
"description.wurst.setting.mobspawnesp.hitbox_check.unstable": "Fast but unstable hitbox check. This is known to crash the game sometimes.",
"description.wurst.setting.mobspawnesp.night_color": "Color of the X at positions where mobs can spawn at night.",
"description.wurst.setting.mobspawnesp.day_color": "Color of the X at positions where mobs can always spawn.",
"description.wurst.hack.multiaura": "Faster Killaura that attacks multiple entities at once.",
Expand Down

0 comments on commit 9c5dc1f

Please sign in to comment.