Skip to content

Commit

Permalink
removed cloth cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
SymoHTL committed Apr 17, 2024
1 parent 56588f0 commit dc2c109
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 63 deletions.
19 changes: 14 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,19 @@ base {
}

repositories {
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases/" }
maven {
name = 'Ladysnake Mods'
url = 'https://maven.ladysnake.org/releases'
content {
includeGroup 'io.github.ladysnake'
includeGroup 'org.ladysnake'
includeGroupByRegex 'dev\\.onyxstudios.*'
}
}

mavenCentral()
maven { url 'https://jitpack.io' }
}

loom {
Expand All @@ -34,10 +45,8 @@ dependencies {

modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modApi ("me.shedaniel.cloth:cloth-config-fabric:13.0.121") {
exclude(group: "net.fabricmc.fabric-api")
}

include modImplementation("com.github.0x3C50:Renderer:master-SNAPSHOT")

}

processResources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ private void renderBlockOverlay(DrawContext drawContext) {
yTextAddOffset++;
}

var x = width / 2 - 70;
var y = 16;
var x = width / 2 - 62;
var y = 24;
UiRenderer.drawItem(drawContext, new ItemStack(block.asItem()), x, y, 32);
}

Expand Down
17 changes: 13 additions & 4 deletions src/client/java/dev/symo/finz/modules/impl/esp/ItemESP.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import dev.symo.finz.util.Category;
import dev.symo.finz.util.UiRenderer;
import dev.symo.finz.util.WorldSpaceRenderer;
import me.x150.renderer.util.RendererUtils;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;
Expand All @@ -28,11 +29,15 @@ public class ItemESP extends AModule implements TickListener, WorldRenderListene
private final IntSetting itemEspRange = new IntSetting("Range", "Range to scan for items",
50, 1, 100);

private final IntSetting scale = new IntSetting("Scale", "Scale of the item sprite",
14, 1, 100);


public ItemESP() {
super("ItemESP", Category.RENDER);
addSetting(itemEspRange);
addSetting(renderItemSprite);
addSetting(scale);
}

@Override
Expand Down Expand Up @@ -67,15 +72,19 @@ public void onWorldRender(MatrixStack matrices, float partialTicks, WorldRenderC

@Override
public void onHudRender(DrawContext drawContext, float tickDelta) {
if (mc.player == null) return;
if (!renderItemSprite.getValue()) return;

var playerPos = mc.player.getPos();

for (Entity item : items) {
Vec3d screenPos = UiRenderer.worldSpaceToScreenSpace(item.getPos());
if (!UiRenderer.screenSpaceCoordinateIsVisible(screenPos)) continue;
var itemPos = item.getPos();
itemPos = itemPos.add(0, item.getHeight() / 2, 0);
Vec3d screenPos = RendererUtils.worldSpaceToScreenSpace(itemPos);
if (!RendererUtils.screenSpaceCoordinateIsVisible(screenPos)) continue;

var itemStack = ((ItemEntity) item).getStack();

UiRenderer.drawItem(drawContext, itemStack, (int) screenPos.x, (int) screenPos.z, 32);
UiRenderer.drawItem(drawContext, itemStack, (int) screenPos.x, (int) screenPos.y, scale.getValue());
}
}
}
51 changes: 2 additions & 49 deletions src/client/java/dev/symo/finz/util/UiRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,22 @@

import com.mojang.blaze3d.systems.RenderSystem;
import dev.symo.finz.FinZClient;
import net.fabricmc.fabric.mixin.blockview.WorldViewMixin;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.json.ModelTransformationMode;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Vec2f;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.WorldView;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f;
import org.joml.Quaternionf;
import org.joml.Vector3f;
import org.joml.Vector4f;
import org.lwjgl.opengl.GL11;
import org.lwjgl.system.Checks;

public class UiRenderer {

@ApiStatus.Internal
public static final Matrix4f lastProjMat = new Matrix4f();
@ApiStatus.Internal
public static final Matrix4f lastModMat = new Matrix4f();
@ApiStatus.Internal
public static final Matrix4f lastWorldSpaceMatrix = new Matrix4f();

private static final MinecraftClient client = MinecraftClient.getInstance();

public static Vec3d worldSpaceToScreenSpace(Vec3d pos) {
Camera camera = client.getEntityRenderDispatcher().camera;
int displayHeight = client.getWindow().getHeight();
int[] viewport = new int[4];
GL11.glGetIntegerv(GL11.GL_VIEWPORT, viewport);
Vector3f target = new Vector3f();

double deltaX = pos.x - camera.getPos().x;
double deltaY = pos.y - camera.getPos().y;
double deltaZ = pos.z - camera.getPos().z;

Vector4f transformedCoordinates = new Vector4f((float) deltaX, (float) deltaY, (float) deltaZ, 1.f).mul(
lastWorldSpaceMatrix);

Matrix4f matrixProj = new Matrix4f(lastProjMat);
Matrix4f matrixModel = new Matrix4f(lastModMat);

matrixProj.mul(matrixModel)
.project(transformedCoordinates.x(), transformedCoordinates.y(), transformedCoordinates.z(), viewport,
target);

return new Vec3d(target.x / client.getWindow().getScaleFactor(),
(displayHeight - target.y) / client.getWindow().getScaleFactor(), target.z);
}

public static boolean screenSpaceCoordinateIsVisible(Vec3d pos) {
return pos != null && pos.z > -1 && pos.z < 1;
}


public static void drawRectDouble(DrawContext drawContext, double left, double top, double right, double bottom, int color) {
if (left < right) {
Expand All @@ -89,7 +41,8 @@ public static void drawItem(DrawContext context, ItemStack stack, int x, int y,
var vertexConsumers = context.getVertexConsumers();
BakedModel bakedModel = FinZClient.mc.getItemRenderer().getModel(stack, FinZClient.mc.world, FinZClient.mc.player, 0);
matrices.push();
matrices.translate((float) (x + 8), (float) (y + 8), 150);
//matrices.translate((float) (x + 8), (float) (y + 8), 150);
matrices.translate(x , y, 150);

matrices.multiplyPositionMatrix((new Matrix4f()).scaling(1.0F, -1.0F, 1.0F));
matrices.scale(scale, scale, scale);
Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,5 @@
"minecraft": "~1.20.4",
"java": ">=17",
"fabric-api": "*"
},
"suggests": {
"cloth-config-fabric": "13.x"
}
}

0 comments on commit dc2c109

Please sign in to comment.