Skip to content

Commit

Permalink
ESP crash hotfix and InvTweaks button pos (MeteorDevelopment#3273)
Browse files Browse the repository at this point in the history
  • Loading branch information
hexadecimal233 authored Feb 2, 2023
1 parent 7834230 commit 3a17c4f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import meteordevelopment.meteorclient.systems.modules.render.NoRender;
import meteordevelopment.meteorclient.utils.Utils;
import meteordevelopment.meteorclient.utils.entity.fakeplayer.FakePlayerEntity;
import meteordevelopment.meteorclient.utils.render.color.Color;
import meteordevelopment.meteorclient.utils.render.postprocess.PostProcessShaders;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
Expand Down Expand Up @@ -105,7 +106,8 @@ else if ((Object) this instanceof LivingEntity) {
@Inject(method = "getTeamColorValue", at = @At("HEAD"), cancellable = true)
private void onGetTeamColorValue(CallbackInfoReturnable<Integer> info) {
if (PostProcessShaders.rendering) {
info.setReturnValue(Modules.get().get(ESP.class).getColor((Entity) (Object) this).getPacked());
Color color = Modules.get().get(ESP.class).getColor((Entity) (Object) this);
if (color != null) info.setReturnValue(color.getPacked());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ private void onInit(CallbackInfo info) {
if (invTweaks.isActive() && invTweaks.showButtons() && invTweaks.canSteal(getScreenHandler())) {
addDrawableChild(
new ButtonWidget.Builder(Text.literal("Steal"), button -> invTweaks.steal(getScreenHandler()))
.position(width / 2 - 40, 3)
.position(width / 2 - 41, 3)
.size(40, 20)
.build()
);

addDrawableChild(
new ButtonWidget.Builder(Text.literal("Dump"), button -> invTweaks.dump(getScreenHandler()))
.position(width / 2 - 40, 26)
.position(width / 2 + 2, 3)
.size(40, 20)
.build()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.function.Supplier;

@Mixin(WorldRenderer.class)
public abstract class WorldRendererMixin {
@Shadow
Expand Down Expand Up @@ -74,16 +72,13 @@ private void onRenderHead(MatrixStack matrices, float tickDelta, long limitTime,

@Inject(method = "renderEntity", at = @At("HEAD"))
private void renderEntity(Entity entity, double cameraX, double cameraY, double cameraZ, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo info) {
draw(entity, cameraX, cameraY, cameraZ, tickDelta, vertexConsumers, matrices, PostProcessShaders.CHAMS, () -> Color.WHITE);
draw(entity, cameraX, cameraY, cameraZ, tickDelta, vertexConsumers, matrices, PostProcessShaders.ENTITY_OUTLINE, () -> Modules.get().get(ESP.class).getColor(entity));
draw(entity, cameraX, cameraY, cameraZ, tickDelta, vertexConsumers, matrices, PostProcessShaders.CHAMS, Color.WHITE);
draw(entity, cameraX, cameraY, cameraZ, tickDelta, vertexConsumers, matrices, PostProcessShaders.ENTITY_OUTLINE, Modules.get().get(ESP.class).getColor(entity));
}

@Unique
private void draw(Entity entity, double cameraX, double cameraY, double cameraZ, float tickDelta, VertexConsumerProvider vertexConsumers, MatrixStack matrices, EntityShader shader, Supplier<Color> colorSupplier) {
if (shader.shouldDraw(entity) && !PostProcessShaders.isCustom(vertexConsumers)) {
Color color = colorSupplier.get();
if (color == null) return;

private void draw(Entity entity, double cameraX, double cameraY, double cameraZ, float tickDelta, VertexConsumerProvider vertexConsumers, MatrixStack matrices, EntityShader shader, Color color) {
if (shader.shouldDraw(entity) && !PostProcessShaders.isCustom(vertexConsumers) && color != null) {
Framebuffer prevBuffer = this.entityOutlinesFramebuffer;
this.entityOutlinesFramebuffer = shader.framebuffer;
PostProcessShaders.rendering = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import net.minecraft.util.math.MathHelper;
import org.joml.Vector3d;

import javax.annotation.Nullable;

public class ESP extends Module {
private final SettingGroup sgGeneral = settings.getDefaultGroup();
private final SettingGroup sgColors = settings.createGroup("Colors");
Expand Down Expand Up @@ -83,7 +81,7 @@ public class ESP extends Module {
.name("fill-opacity")
.description("The opacity of the shape fill.")
.visible(() -> shapeMode.get() != ShapeMode.Lines)
.defaultValue(0.8)
.defaultValue(0.3)
.range(0, 1)
.sliderMax(1)
.build()
Expand Down Expand Up @@ -202,8 +200,10 @@ private void onRender3D(Render3DEvent event) {

private void drawBoundingBox(Render3DEvent event, Entity entity) {
Color color = getColor(entity);
lineColor.set(color);
sideColor.set(color).a((int) (sideColor.a * fillOpacity.get()));
if (color != null) {
lineColor.set(color);
sideColor.set(color).a((int) (sideColor.a * fillOpacity.get()));
}

if (mode.get() == Mode.Box) {
double x = MathHelper.lerp(event.tickDelta, entity.lastRenderX, entity.getX()) - entity.getX();
Expand All @@ -212,8 +212,7 @@ private void drawBoundingBox(Render3DEvent event, Entity entity) {

Box box = entity.getBoundingBox();
event.renderer.box(x + box.minX, y + box.minY, z + box.minZ, x + box.maxX, y + box.maxY, z + box.maxZ, sideColor, lineColor, shapeMode.get(), 0);
}
else {
} else {
WireframeEntityRenderer.render(event, entity, 1, sideColor, lineColor, shapeMode.get());
}
}
Expand Down Expand Up @@ -254,8 +253,10 @@ private void onRender2D(Render2DEvent event) {

// Setup color
Color color = getColor(entity);
lineColor.set(color);
sideColor.set(color).a((int) (sideColor.a * fillOpacity.get()));
if (color != null) {
lineColor.set(color);
sideColor.set(color).a((int) (sideColor.a * fillOpacity.get()));
}

// Render
if (shapeMode.get() != ShapeMode.Lines && sideColor.a > 0) {
Expand Down Expand Up @@ -301,7 +302,6 @@ public boolean shouldSkip(Entity entity) {
return !EntityUtils.isInRenderDistance(entity);
}

@Nullable
public Color getColor(Entity entity) {
if (!entities.get().getBoolean(entity.getType())) return null;

Expand Down

0 comments on commit 3a17c4f

Please sign in to comment.