diff --git a/src/main/java/dev/heliosclient/managers/ColorManager.java b/src/main/java/dev/heliosclient/managers/ColorManager.java index 4feb307..5898f12 100644 --- a/src/main/java/dev/heliosclient/managers/ColorManager.java +++ b/src/main/java/dev/heliosclient/managers/ColorManager.java @@ -187,7 +187,7 @@ public void onTick(TickEvent.CLIENT e) { if (gui.ColorMode.value == 0) { updatePrimaryGradients(gui.staticColor.getColor(), gui.staticColor.getColor()); }else if (gui.ColorMode.value == 1) { - updatePrimaryGradients(gui.gradientType.get().getStartGradient(), gui.gradientType.get().getEndGradient()); + updatePrimaryGradients(gui.gradientType.get().getStartColor(), gui.gradientType.get().getEndColor()); } updateClickGuiSecondary(HeliosClient.CLICKGUI.AccentColor.getColor(), HeliosClient.CLICKGUI.AccentColor.isRainbow()); diff --git a/src/main/java/dev/heliosclient/managers/GradientManager.java b/src/main/java/dev/heliosclient/managers/GradientManager.java index aeaf4f0..2428bab 100644 --- a/src/main/java/dev/heliosclient/managers/GradientManager.java +++ b/src/main/java/dev/heliosclient/managers/GradientManager.java @@ -38,24 +38,24 @@ public static String getKeyForGradient(Gradient gradient) { public static class Gradient { - private final Supplier startGradient; - private final Supplier endGradient; + private final Supplier startColor; + private final Supplier endColor; - public static Gradient of(Supplier startGradient, Supplier endGradient){ - return new Gradient(startGradient, endGradient); + public static Gradient of(Supplier startColor, Supplier endGradient){ + return new Gradient(startColor, endGradient); } - public Gradient(Supplier startGradient, Supplier endGradient) { - this.startGradient = startGradient; - this.endGradient = endGradient; + public Gradient(Supplier startColor, Supplier endColor) { + this.startColor = startColor; + this.endColor = endColor; } - public Color getStartGradient() { - return startGradient.get(); + public Color getStartColor() { + return startColor.get(); } - public Color getEndGradient() { - return endGradient.get(); + public Color getEndColor() { + return endColor.get(); } } diff --git a/src/main/java/dev/heliosclient/module/modules/movement/NoFall.java b/src/main/java/dev/heliosclient/module/modules/movement/NoFall.java index 005c013..710b2c5 100644 --- a/src/main/java/dev/heliosclient/module/modules/movement/NoFall.java +++ b/src/main/java/dev/heliosclient/module/modules/movement/NoFall.java @@ -13,6 +13,7 @@ import dev.heliosclient.util.player.InventoryUtils; import dev.heliosclient.util.player.RotationUtils; import net.minecraft.block.Block; +import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.LeavesBlock; import net.minecraft.fluid.Fluids; @@ -196,14 +197,12 @@ private void clutch(PlayerMotionEvent event) { event.modifyMovement().heliosClient$setXZ(0, 0); } - BlockHitResult result = mc.world.raycast(new RaycastContext(mc.player.getPos(), mc.player.getPos().subtract(0, mc.interactionManager.getReachDistance() - 1, 0), RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, mc.player)); + BlockHitResult result = mc.world.raycast(new RaycastContext(mc.player.getPos(), mc.player.getPos().subtract(0, mc.interactionManager.getReachDistance(), 0), RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, mc.player)); if (result != null && result.getType() == HitResult.Type.BLOCK) { - BlockPos bpDown = result.getBlockPos(); - if (!isPlayerAlreadySafe(result.getBlockPos())) { for (ClutchItem item : ClutchItem.values()) { - cm.clutch(item, bpDown,event); + cm.clutch(item, result.getBlockPos(), event); if (cm.hasClutchedProperly()) { break; } @@ -216,22 +215,26 @@ private void clutch(PlayerMotionEvent event) { } private boolean shouldResetClutch() { - return mc.player.isOnGround() || - mc.player.getBlockStateAtPos().getFluidState() != Fluids.EMPTY.getDefaultState() || - mc.player.fallDistance < fallHeight.value; + return mc.player.isOnGround() || + mc.player.getBlockStateAtPos().getFluidState() != Fluids.EMPTY.getDefaultState() || + mc.player.fallDistance < fallHeight.value; } - public boolean isPlayerAlreadySafe(BlockPos blockPos) { + public boolean isPlayerAlreadySafe(BlockPos collidingBlockPos) { + //We don't need to force place in water + BlockState state = mc.world.getBlockState(collidingBlockPos); + if(state.getFluidState().isOf(Fluids.WATER) || state.getFluidState().isOf(Fluids.FLOWING_WATER)) return true; + if (forcePlace.value) { return false; } - Block block = mc.world.getBlockState(blockPos).getBlock(); + Block block = state.getBlock(); - //If block is clutch item then it's probably safe. (probably because we are not accounting fallDistance for now, + // If block is clutch item then it's probably safe. (probably because we are not accounting fallDistance for now, // meaning haybales and slimeblocks may still kill you). for (ClutchItem item : ClutchItem.values()) { - if (item.getBlock() == block || block.getDefaultState().isLiquid()) { + if (item.getBlock() == block) { return true; } } @@ -242,9 +245,9 @@ public boolean isPlayerAlreadySafe(BlockPos blockPos) { public enum ClutchItem { WATER_BUCKET(Items.WATER_BUCKET, Items.BUCKET, Blocks.WATER), - POWDER_SNOW_BUCKET(Items.POWDER_SNOW_BUCKET, Items.BUCKET, Blocks.POWDER_SNOW), HAY_BLOCK(Items.HAY_BLOCK, null, Blocks.HAY_BLOCK), SLIME_BLOCK(Items.SLIME_BLOCK, null, Blocks.SLIME_BLOCK), + POWDER_SNOW_BUCKET(Items.POWDER_SNOW_BUCKET, Items.BUCKET, Blocks.POWDER_SNOW), COB_WEB(Items.COBWEB, null, Blocks.COBWEB); diff --git a/src/main/java/dev/heliosclient/module/modules/render/BlockSelection.java b/src/main/java/dev/heliosclient/module/modules/render/BlockSelection.java index 4e38334..7183d97 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/BlockSelection.java +++ b/src/main/java/dev/heliosclient/module/modules/render/BlockSelection.java @@ -4,10 +4,7 @@ import dev.heliosclient.event.events.render.Render3DEvent; import dev.heliosclient.module.Categories; import dev.heliosclient.module.Module_; -import dev.heliosclient.module.settings.BooleanSetting; -import dev.heliosclient.module.settings.DoubleSetting; -import dev.heliosclient.module.settings.RGBASetting; -import dev.heliosclient.module.settings.SettingGroup; +import dev.heliosclient.module.settings.*; import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer3D; import dev.heliosclient.util.render.color.QuadColor; @@ -20,6 +17,7 @@ import org.apache.commons.lang3.ArrayUtils; import java.awt.*; +import java.util.List; public class BlockSelection extends Module_ { SettingGroup sgGeneral = new SettingGroup("General"); @@ -32,6 +30,14 @@ public class BlockSelection extends Module_ { .onSettingChange(this) .build() ); + BooleanSetting fill = sgGeneral.add(new BooleanSetting.Builder() + .name("Fill") + .description("Draw side fill of holes") + .value(true) + .defaultValue(true) + .onSettingChange(this) + .build() + ); BooleanSetting outline = sgGeneral.add(new BooleanSetting.Builder() .name("Outline") .description("Draw outline of holes") @@ -61,12 +67,37 @@ public class BlockSelection extends Module_ { .build() ); - BooleanSetting fill = sgGeneral.add(new BooleanSetting.Builder() - .name("Fill") - .description("Draw side fill of holes") - .value(true) - .defaultValue(true) + BooleanSetting gradient = sgGeneral.add(new BooleanSetting.Builder() + .name("Gradient") + .description("Uses gradients instead of static single fill colors") + .value(false) + .defaultValue(false) + .onSettingChange(this) + .build() + ); + CycleSetting gradientDirection = sgGeneral.add(new CycleSetting.Builder() + .name("Gradient Direction") + .description("Direction of gradient") + .value(List.of(QuadColor.CardinalDirection.values())) + .defaultListOption(QuadColor.CardinalDirection.DIAGONAL_LEFT) + .onSettingChange(this) + .shouldRender(()-> gradient.value) + .build() + ); + GradientSetting fillGradient = sgGeneral.add(new GradientSetting.Builder() + .name("Fill Gradient") + .description("Gradient of the fill") + .defaultValue("Rainbow") + .onSettingChange(this) + .shouldRender(()-> gradient.value) + .build() + ); + GradientSetting lineGradient = sgGeneral.add(new GradientSetting.Builder() + .name("Line Gradient") + .description("Gradient of the outline") + .defaultValue("Rainbow") .onSettingChange(this) + .shouldRender(()-> gradient.value) .build() ); RGBASetting fillColor = sgGeneral.add(new RGBASetting.Builder() @@ -74,16 +105,18 @@ public class BlockSelection extends Module_ { .description("Color of the Fill") .defaultValue(ColorUtils.changeAlpha(Color.WHITE, 125)) .onSettingChange(this) + .shouldRender(()-> !gradient.value) .rainbow(false) .build() ); RGBASetting lineColor = sgGeneral.add(new RGBASetting.Builder() .name("Line color") - .description("Color of the line") + .description("Color of the outline") .value(Color.WHITE) .defaultValue(Color.WHITE) .onSettingChange(this) + .shouldRender(()-> !gradient.value) .rainbow(false) .build() ); @@ -128,12 +161,16 @@ public void renderBlockHitResult(BlockHitResult result, boolean doEmptyRender) { } public void renderSelection(Box box,Direction... exclude) { + QuadColor.CardinalDirection gradientDirection = (QuadColor.CardinalDirection) this.gradientDirection.getOption(); + QuadColor fillColor = gradient.value ? QuadColor.gradient(fillGradient.getStartColor().getRGB(), fillGradient.getEndColor().getRGB(),gradientDirection) : QuadColor.single(this.fillColor.value.getRGB()); + QuadColor lineColor = gradient.value ? QuadColor.gradient(lineGradient.getStartColor().getRGB(), lineGradient.getEndColor().getRGB(), gradientDirection) : QuadColor.single(this.lineColor.value.getRGB()); + if (outline.value && fill.value) { - Renderer3D.drawBoxBoth(box, QuadColor.single(fillColor.value.getRGB()), QuadColor.single(lineColor.value.getRGB()), (float) outlineWidth.value,exclude); + Renderer3D.drawBoxBoth(box, fillColor, lineColor, (float) outlineWidth.value,exclude); } else if (outline.value) { - Renderer3D.drawBoxOutline(box, QuadColor.single(lineColor.value.getRGB()), (float) outlineWidth.value,exclude); + Renderer3D.drawBoxOutline(box, lineColor, (float) outlineWidth.value,exclude); } else if (fill.value) { - Renderer3D.drawBoxFill(box, QuadColor.single(fillColor.value.getRGB()),exclude); + Renderer3D.drawBoxFill(box, fillColor,exclude); } } } \ No newline at end of file diff --git a/src/main/java/dev/heliosclient/module/modules/render/BreakIndicator.java b/src/main/java/dev/heliosclient/module/modules/render/BreakIndicator.java index 7f1870d..eab6e41 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/BreakIndicator.java +++ b/src/main/java/dev/heliosclient/module/modules/render/BreakIndicator.java @@ -97,8 +97,8 @@ public void onRender3d(Render3DEvent event) { BlockState state = mc.world.getBlockState(currentBreakingPos); VoxelShape shape = state.getOutlineShape(mc.world, currentBreakingPos); if (shape == null || shape.isEmpty()) return; - int start = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getStartGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); - int end = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getEndGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); + int start = gradientBool.value ? ColorUtils.changeAlpha(gradient.getStartColor().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); + int end = gradientBool.value ? ColorUtils.changeAlpha(gradient.getEndColor().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); renderIndicator(shape.getBoundingBox().expand(0.001f).offset(currentBreakingPos), selfBreakingProgress/10.0f, (IndicateType) type.getOption(),start,end); } @@ -113,8 +113,8 @@ public void onRender3d(Render3DEvent event) { VoxelShape shape = state.getOutlineShape(mc.world, pos); if (shape == null || shape.isEmpty()) return; - int start = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getStartGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); - int end = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getEndGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); + int start = gradientBool.value ? ColorUtils.changeAlpha(gradient.getStartColor().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); + int end = gradientBool.value ? ColorUtils.changeAlpha(gradient.getEndColor().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); renderIndicator(shape.getBoundingBox().expand(0.001f).offset(pos), (float) (breakProgress + 1) / 10, (IndicateType) type.getOption(),start,end); }); diff --git a/src/main/java/dev/heliosclient/module/modules/render/CustomCrosshair.java b/src/main/java/dev/heliosclient/module/modules/render/CustomCrosshair.java index 60822bc..b291dbd 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/CustomCrosshair.java +++ b/src/main/java/dev/heliosclient/module/modules/render/CustomCrosshair.java @@ -146,8 +146,8 @@ public void renderSquare(DrawContext dr, int x, int y, int width, int height) { } public void renderInverseTriangleGap(DrawContext dr, int x, int y) { - Color startG = colorMode.value == 0 ? staticColor.getColor() : gradientType.get().getStartGradient(); - Color endG = colorMode.value == 0 ? staticColor.getColor() : gradientType.get().getEndGradient(); + Color startG = colorMode.value == 0 ? staticColor.getColor() : gradientType.getStartColor(); + Color endG = colorMode.value == 0 ? staticColor.getColor() : gradientType.getEndColor(); Matrix4f mc = dr.getMatrices().peek().getPositionMatrix(); //left @@ -177,8 +177,8 @@ private int getSize() { } public void mask(DrawContext dr, Runnable task, int x, int y, int width, int height) { - Color startG = colorMode.value == 0 ? staticColor.getColor() : gradientType.get().getStartGradient(); - Color endG = colorMode.value == 0 ? staticColor.getColor() : gradientType.get().getEndGradient(); + Color startG = colorMode.value == 0 ? staticColor.getColor() : gradientType.getStartColor(); + Color endG = colorMode.value == 0 ? staticColor.getColor() : gradientType.getEndColor(); Renderer2D.drawToGradientMask(dr.getMatrices().peek().getPositionMatrix(), startG, diff --git a/src/main/java/dev/heliosclient/module/modules/render/HoleESP.java b/src/main/java/dev/heliosclient/module/modules/render/HoleESP.java index 907c309..a69d66f 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/HoleESP.java +++ b/src/main/java/dev/heliosclient/module/modules/render/HoleESP.java @@ -121,6 +121,7 @@ public class HoleESP extends Module_ { .build() ); SettingGroup sgColor = new SettingGroup("Color"); + CycleSetting gradientDirection = sgColor.add(new CycleSetting.Builder() .name("Gradient Direction") .description("Direction of gradient, up/down") diff --git a/src/main/java/dev/heliosclient/module/modules/world/PacketMine.java b/src/main/java/dev/heliosclient/module/modules/world/PacketMine.java index a0aad71..9cf592a 100644 --- a/src/main/java/dev/heliosclient/module/modules/world/PacketMine.java +++ b/src/main/java/dev/heliosclient/module/modules/world/PacketMine.java @@ -225,8 +225,8 @@ public void render3d(Render3DEvent event) { VoxelShape shape = state.getOutlineShape(mc.world, pos); if (shape == null || shape.isEmpty()) return; - int start = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getStartGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); - int end = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getEndGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); + int start = gradientBool.value ? ColorUtils.changeAlpha(gradient.getStartColor().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); + int end = gradientBool.value ? ColorUtils.changeAlpha(gradient.getEndColor().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); ModuleManager.get(BreakIndicator.class).renderIndicator(shape.getBoundingBox().expand(0.001f).offset(pos), (float) info.progress, (BreakIndicator.IndicateType) type.getOption(),start,end); }); diff --git a/src/main/java/dev/heliosclient/module/settings/GradientSetting.java b/src/main/java/dev/heliosclient/module/settings/GradientSetting.java index fdda1e0..36b1ed0 100644 --- a/src/main/java/dev/heliosclient/module/settings/GradientSetting.java +++ b/src/main/java/dev/heliosclient/module/settings/GradientSetting.java @@ -39,20 +39,21 @@ public GradientSetting(String name, String description, BooleanSupplier shouldRe checkGradientAvailability(); } - private void checkGradientAvailability(){ - if(defaultValue == null){ + + private void checkGradientAvailability() { + if (defaultValue == null) { Optional optional = gradientList.stream().findFirst(); - optional.ifPresent(s ->{ + optional.ifPresent(s -> { this.value = GradientManager.getGradient(s); this.defaultValue = value; }); } } - public void createTable(double width){ + public void createTable(double width) { gradientTable = new Table(); - for(String gradientName: gradientList){ + for (String gradientName : gradientList) { gradientTable.addEntry(new GradientEntry(GradientManager.getGradient(gradientName)), width); } } @@ -73,10 +74,10 @@ public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY //Draw preview Renderer2D.drawRoundedGradientRectangle(drawContext.getMatrices().peek().getPositionMatrix(), - this.value.getStartGradient(), - this.value.getEndGradient(), - this.value.getEndGradient(), - this.value.getStartGradient(), + this.value.getStartColor(), + this.value.getEndColor(), + this.value.getEndColor(), + this.value.getStartColor(), x + width - 50, y + 2, 40, @@ -84,53 +85,54 @@ public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY 3 ); } - public boolean isLinear2D(){ + + public boolean isLinear2D() { return Objects.requireNonNull(GradientManager.getKeyForGradient(this.value)).equalsIgnoreCase("Linear2D"); } - public void renderAllGradients(DrawContext context, int mouseX, int mouseY){ + public void renderAllGradients(DrawContext context, int mouseX, int mouseY) { for (List row : gradientTable.table) { for (TableEntry entry : row) { if (entry instanceof GradientEntry gE) { - boolean isMouseOver = ListSetting.isMouseOver(mouseX,mouseY,(float) gE.x + 3,(float) gE.y,(float) gE.width - 3, 18); + boolean isMouseOver = ListSetting.isMouseOver(mouseX, mouseY, (float) gE.x + 3, (float) gE.y, (float) gE.width - 3, 18); - float y = (float) gE.y - (isMouseOver? 1 : 0); + float y = (float) gE.y - (isMouseOver ? 1 : 0); Renderer2D.drawRoundedGradientRectangleWithShadow(context.getMatrices(), (float) gE.x + 3, y, (float) gE.width - 3, 18, - gE.gradient.getStartGradient(), - gE.gradient.getEndGradient(), - gE.gradient.getEndGradient(), - gE.gradient.getStartGradient(), + gE.gradient.getStartColor(), + gE.gradient.getEndColor(), + gE.gradient.getEndColor(), + gE.gradient.getStartColor(), 3, 20, - gE.gradient.getStartGradient() + gE.gradient.getStartColor() ); - if(this.value == gE.gradient){ + if (this.value == gE.gradient) { Renderer2D.drawOutlineRoundedBox(context.getMatrices().peek().getPositionMatrix(), - (float)gE.x + 2, + (float) gE.x + 2, y, (float) gE.width - 2, 19, 3f, 1.2f, Color.WHITE.getRGB() - ); + ); } String nameOfG = GradientManager.getKeyForGradient(gE.gradient); - if(nameOfG == null){ + if (nameOfG == null) { nameOfG = "Unknown"; - }else{ + } else { nameOfG = nameOfG.trim(); } - Renderer2D.drawCustomString(FontRenderers.Mid_fxfontRenderer,context.getMatrices(),nameOfG,(float) (gE.x + gE.width/2.0f - Renderer2D.getCustomStringWidth(nameOfG,FontRenderers.Mid_fxfontRenderer)/2.0f + 1),y + 9 - Renderer2D.getCustomStringHeight(nameOfG,FontRenderers.Mid_fxfontRenderer)/2.0f,-1); + Renderer2D.drawCustomString(FontRenderers.Mid_fxfontRenderer, context.getMatrices(), nameOfG, (float) (gE.x + gE.width / 2.0f - Renderer2D.getCustomStringWidth(nameOfG, FontRenderers.Mid_fxfontRenderer) / 2.0f + 1), y + 9 - Renderer2D.getCustomStringHeight(nameOfG, FontRenderers.Mid_fxfontRenderer) / 2.0f, -1); } } } @@ -152,10 +154,10 @@ public void renderCompact(DrawContext drawContext, int x, int y, int mouseX, int //Draw preview Renderer2D.drawRoundedGradientRectangle(drawContext.getMatrices().peek().getPositionMatrix(), - this.value.getStartGradient(), - this.value.getEndGradient(), - this.value.getEndGradient(), - this.value.getStartGradient(), + this.value.getStartColor(), + this.value.getEndColor(), + this.value.getEndColor(), + this.value.getStartColor(), x + moduleWidth - 15, y + 2, 12, @@ -190,6 +192,12 @@ public GradientManager.Gradient get() { } return this.value; } + public Color getStartColor(){ + return get().getStartColor(); + } + public Color getEndColor(){ + return get().getEndColor(); + } @Override public Object saveToFile(List objectList) { @@ -207,6 +215,7 @@ public void loadFromFile(MapReader map) { this.value = GradientManager.getGradient(mapVal.toString()); } + @Override public void setValue(GradientManager.Gradient value) { this.value = value; diff --git a/src/main/java/dev/heliosclient/system/HeliosExecutor.java b/src/main/java/dev/heliosclient/system/HeliosExecutor.java index 8759e62..6df1013 100644 --- a/src/main/java/dev/heliosclient/system/HeliosExecutor.java +++ b/src/main/java/dev/heliosclient/system/HeliosExecutor.java @@ -16,7 +16,8 @@ public class HeliosExecutor { }); public static void execute(Runnable task) { - executorService.execute(task); + if(task != null) + executorService.execute(task); } public static void shutdown() { diff --git a/src/main/java/dev/heliosclient/ui/clickgui/gui/PolygonMeshPatternRenderer.java b/src/main/java/dev/heliosclient/ui/clickgui/gui/PolygonMeshPatternRenderer.java index 598d172..0c73286 100644 --- a/src/main/java/dev/heliosclient/ui/clickgui/gui/PolygonMeshPatternRenderer.java +++ b/src/main/java/dev/heliosclient/ui/clickgui/gui/PolygonMeshPatternRenderer.java @@ -43,7 +43,7 @@ public void setNumOfPoints(int NUM_POINTS) { } public void render(MatrixStack matrixStack, int mouseX, int mouseY) { - Renderer2D.drawToGradientMask(matrixStack.peek().getPositionMatrix(), maskGradient.getStartGradient(), maskGradient.getEndGradient(), maskGradient.getEndGradient(), maskGradient.getStartGradient(), 0, 0, MinecraftClient.getInstance().getWindow().getScaledWidth(), MinecraftClient.getInstance().getWindow().getScaledHeight(), () -> { + Renderer2D.drawToGradientMask(matrixStack.peek().getPositionMatrix(), maskGradient.getStartColor(), maskGradient.getEndColor(), maskGradient.getEndColor(), maskGradient.getStartColor(), 0, 0, MinecraftClient.getInstance().getWindow().getScaledWidth(), MinecraftClient.getInstance().getWindow().getScaledHeight(), () -> { for (Point point : points) { point.move(mouseX, mouseY); point.display(matrixStack); diff --git a/src/main/java/dev/heliosclient/util/render/TargetRenderer.java b/src/main/java/dev/heliosclient/util/render/TargetRenderer.java index a1a2be9..5c87399 100644 --- a/src/main/java/dev/heliosclient/util/render/TargetRenderer.java +++ b/src/main/java/dev/heliosclient/util/render/TargetRenderer.java @@ -24,13 +24,13 @@ public void set(LivingEntity targetEntity){ public void render(){ if(targetEntity == null)return; - QuadColor color = QuadColor.gradient(this.color.getStartGradient().getRGB(),this.color.getEndGradient().getRGB(),dir); + QuadColor color = QuadColor.gradient(this.color.getStartColor().getRGB(),this.color.getEndColor().getRGB(),dir); switch (renderMode){ case Circle -> Renderer3D.drawFlatFilledCircle(radius,Renderer3D.getInterpolatedPosition(targetEntity),320,color); case Outline -> Renderer3D.drawBoxOutline(targetEntity.getBoundingBox(),color,3f); case WireFrame, - PlayerSkeleton -> WireframeEntityRenderer.render(targetEntity,1.0f,color, LineColor.gradient(this.color.getStartGradient().getRGB(),this.color.getEndGradient().getRGB()),1.5f,true,true,renderMode == RenderMode.PlayerSkeleton); + PlayerSkeleton -> WireframeEntityRenderer.render(targetEntity,1.0f,color, LineColor.gradient(this.color.getStartColor().getRGB(),this.color.getEndColor().getRGB()),1.5f,true,true,renderMode == RenderMode.PlayerSkeleton); } } diff --git a/src/main/java/dev/heliosclient/util/render/Vertexer.java b/src/main/java/dev/heliosclient/util/render/Vertexer.java index 2619a6b..65ddc0d 100644 --- a/src/main/java/dev/heliosclient/util/render/Vertexer.java +++ b/src/main/java/dev/heliosclient/util/render/Vertexer.java @@ -53,23 +53,6 @@ public static void vertexBoxQuads(MatrixStack matrices, VertexConsumer vertexCon vertexQuad(matrices, vertexConsumer, x1, y2, z2, x2, y2, z2, x2, y2, z1, x1, y2, z1, cullMode, quadColor, box); } } - public static void vertexQuad(MatrixStack matrices, VertexConsumer vertexConsumer, float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, int cullMode, QuadColor quadColor) { - int[] color = quadColor.getAllColors(); - - if (cullMode != CULL_FRONT) { - vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x1, y1, z1).color(color[0], color[1], color[2], color[3]).next(); - vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x2, y2, z2).color(color[4], color[5], color[6], color[7]).next(); - vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x3, y3, z3).color(color[8], color[9], color[10], color[11]).next(); - vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x4, y4, z4).color(color[12], color[13], color[14], color[15]).next(); - } - - if (cullMode != CULL_BACK) { - vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x4, y4, z4).color(color[0], color[1], color[2], color[3]).next(); - vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x3, y3, z3).color(color[4], color[5], color[6], color[7]).next(); - vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x2, y2, z2).color(color[8], color[9], color[10], color[11]).next(); - vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x1, y1, z1).color(color[12], color[13], color[14], color[15]).next(); - } - } public static void vertexQuad(MatrixStack matrices, VertexConsumer vertexConsumer, float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, int cullMode, QuadColor quadColor, Box box) { int[] color1 = quadColor.getColorForVertex(x1, y1, z1, box); @@ -92,6 +75,25 @@ public static void vertexQuad(MatrixStack matrices, VertexConsumer vertexConsume } } + public static void vertexQuad(MatrixStack matrices, VertexConsumer vertexConsumer, float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, int cullMode, QuadColor quadColor) { + int[] color = quadColor.getAllColors(); + + if (cullMode != CULL_FRONT) { + vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x1, y1, z1).color(color[0], color[1], color[2], color[3]).next(); + vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x2, y2, z2).color(color[4], color[5], color[6], color[7]).next(); + vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x3, y3, z3).color(color[8], color[9], color[10], color[11]).next(); + vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x4, y4, z4).color(color[12], color[13], color[14], color[15]).next(); + } + + if (cullMode != CULL_BACK) { + vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x4, y4, z4).color(color[0], color[1], color[2], color[3]).next(); + vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x3, y3, z3).color(color[4], color[5], color[6], color[7]).next(); + vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x2, y2, z2).color(color[8], color[9], color[10], color[11]).next(); + vertexConsumer.vertex(matrices.peek().getPositionMatrix(), x1, y1, z1).color(color[12], color[13], color[14], color[15]).next(); + } + } + + public static void vertexBoxLines(MatrixStack matrices, VertexConsumer vertexConsumer, Box box, QuadColor quadColor, Direction... excludeDirs) { float x1 = (float) box.minX; float y1 = (float) box.minY; @@ -107,64 +109,75 @@ public static void vertexBoxLines(MatrixStack matrices, VertexConsumer vertexCon boolean exSouth = ArrayUtils.contains(excludeDirs, Direction.SOUTH); boolean exUp = ArrayUtils.contains(excludeDirs, Direction.UP); - int[] color = quadColor.getAllColors(); - if (!exDown) { - vertexLine(matrices, vertexConsumer, x1, y1, z1, x2, y1, z1, LineColor.single(color[0], color[1], color[2], color[3])); - vertexLine(matrices, vertexConsumer, x2, y1, z1, x2, y1, z2, LineColor.single(color[4], color[5], color[6], color[7])); - vertexLine(matrices, vertexConsumer, x2, y1, z2, x1, y1, z2, LineColor.single(color[8], color[9], color[10], color[11])); - vertexLine(matrices, vertexConsumer, x1, y1, z2, x1, y1, z1, LineColor.single(color[12], color[13], color[14], color[15])); + vertexLine(matrices, vertexConsumer, x1, y1, z1, x2, y1, z1, quadColor, box); + vertexLine(matrices, vertexConsumer, x2, y1, z1, x2, y1, z2, quadColor, box); + vertexLine(matrices, vertexConsumer, x2, y1, z2, x1, y1, z2, quadColor, box); + vertexLine(matrices, vertexConsumer, x1, y1, z2, x1, y1, z1, quadColor, box); } if (!exWest) { if (!exDown) - vertexLine(matrices, vertexConsumer, x1, y1, z1, x1, y1, z2, LineColor.single(color[0], color[1], color[2], color[3])); - vertexLine(matrices, vertexConsumer, x1, y1, z2, x1, y2, z2, LineColor.single(color[4], color[5], color[6], color[7])); - vertexLine(matrices, vertexConsumer, x1, y1, z1, x1, y2, z1, LineColor.single(color[8], color[9], color[10], color[11])); + vertexLine(matrices, vertexConsumer, x1, y1, z1, x1, y1, z2, quadColor, box); + vertexLine(matrices, vertexConsumer, x1, y1, z2, x1, y2, z2, quadColor, box); + vertexLine(matrices, vertexConsumer, x1, y1, z1, x1, y2, z1, quadColor, box); if (!exUp) - vertexLine(matrices, vertexConsumer, x1, y2, z1, x1, y2, z2, LineColor.single(color[12], color[13], color[14], color[15])); + vertexLine(matrices, vertexConsumer, x1, y2, z1, x1, y2, z2, quadColor, box); } if (!exEast) { if (!exDown) - vertexLine(matrices, vertexConsumer, x2, y1, z1, x2, y1, z2, LineColor.single(color[0], color[1], color[2], color[3])); - vertexLine(matrices, vertexConsumer, x2, y1, z2, x2, y2, z2, LineColor.single(color[4], color[5], color[6], color[7])); - vertexLine(matrices, vertexConsumer, x2, y1, z1, x2, y2, z1, LineColor.single(color[8], color[9], color[10], color[11])); + vertexLine(matrices, vertexConsumer, x2, y1, z1, x2, y1, z2, quadColor, box); + vertexLine(matrices, vertexConsumer, x2, y1, z2, x2, y2, z2, quadColor, box); + vertexLine(matrices, vertexConsumer, x2, y1, z1, x2, y2, z1, quadColor, box); if (!exUp) - vertexLine(matrices, vertexConsumer, x2, y2, z1, x2, y2, z2, LineColor.single(color[12], color[13], color[14], color[15])); + vertexLine(matrices, vertexConsumer, x2, y2, z1, x2, y2, z2, quadColor, box); } if (!exNorth) { if (!exDown) - vertexLine(matrices, vertexConsumer, x1, y1, z1, x2, y1, z1, LineColor.single(color[0], color[1], color[2], color[3])); + vertexLine(matrices, vertexConsumer, x1, y1, z1, x2, y1, z1, quadColor, box); if (!exEast) - vertexLine(matrices, vertexConsumer, x2, y1, z1, x2, y2, z1, LineColor.single(color[4], color[5], color[6], color[7])); + vertexLine(matrices, vertexConsumer, x2, y1, z1, x2, y2, z1, quadColor, box); if (!exWest) - vertexLine(matrices, vertexConsumer, x1, y1, z1, x1, y2, z1, LineColor.single(color[8], color[9], color[10], color[11])); + vertexLine(matrices, vertexConsumer, x1, y1, z1, x1, y2, z1, quadColor, box); if (!exUp) - vertexLine(matrices, vertexConsumer, x1, y2, z1, x2, y2, z1, LineColor.single(color[12], color[13], color[14], color[15])); + vertexLine(matrices, vertexConsumer, x1, y2, z1, x2, y2, z1, quadColor, box); } if (!exSouth) { if (!exDown) - vertexLine(matrices, vertexConsumer, x1, y1, z2, x2, y1, z2, LineColor.single(color[0], color[1], color[2], color[3])); + vertexLine(matrices, vertexConsumer, x1, y1, z2, x2, y1, z2, quadColor, box); if (!exEast) - vertexLine(matrices, vertexConsumer, x2, y1, z2, x2, y2, z2, LineColor.single(color[4], color[5], color[6], color[7])); + vertexLine(matrices, vertexConsumer, x2, y1, z2, x2, y2, z2, quadColor, box); if (!exWest) - vertexLine(matrices, vertexConsumer, x1, y1, z2, x1, y2, z2, LineColor.single(color[8], color[9], color[10], color[11])); + vertexLine(matrices, vertexConsumer, x1, y1, z2, x1, y2, z2, quadColor, box); if (!exUp) - vertexLine(matrices, vertexConsumer, x1, y2, z2, x2, y2, z2, LineColor.single(color[12], color[13], color[14], color[15])); + vertexLine(matrices, vertexConsumer, x1, y2, z2, x2, y2, z2, quadColor, box); } - if (!exUp) { - vertexLine(matrices, vertexConsumer, x1, y2, z1, x2, y2, z1, LineColor.single(color[0], color[1], color[2], color[3])); - vertexLine(matrices, vertexConsumer, x2, y2, z1, x2, y2, z2, LineColor.single(color[4], color[5], color[6], color[7])); - vertexLine(matrices, vertexConsumer, x2, y2, z2, x1, y2, z2, LineColor.single(color[8], color[9], color[10], color[11])); - vertexLine(matrices, vertexConsumer, x1, y2, z2, x1, y2, z1, LineColor.single(color[12], color[13], color[14], color[15])); + vertexLine(matrices, vertexConsumer, x1, y2, z1, x2, y2, z1, quadColor, box); + vertexLine(matrices, vertexConsumer, x2, y2, z1, x2, y2, z2, quadColor, box); + vertexLine(matrices, vertexConsumer, x2, y2, z2, x1, y2, z2, quadColor, box); + vertexLine(matrices, vertexConsumer, x1, y2, z2, x1, y2, z1, quadColor, box); } } + public static void vertexLine(MatrixStack matrices, VertexConsumer vertexConsumer, float x1, float y1, float z1, float x2, float y2, float z2, QuadColor quadColor, Box box) { + Matrix4f model = matrices.peek().getPositionMatrix(); + Matrix3f normal = matrices.peek().getNormalMatrix(); + + Vector3f normalVec = getNormal(x1, y1, z1, x2, y2, z2); + + int[] color1 = quadColor.getColorForVertex(x1, y1, z1, box); + int[] color2 = quadColor.getColorForVertex(x2, y2, z2, box); + + vertexConsumer.vertex(model, x1, y1, z1).color(color1[0], color1[1], color1[2], color1[3]).normal(normal, normalVec.x(), normalVec.y(), normalVec.z()).next(); + vertexConsumer.vertex(model, x2, y2, z2).color(color2[0], color2[1], color2[2], color2[3]).normal(normal, normalVec.x(), normalVec.y(), normalVec.z()).next(); + } + + public static void vertexTriangle(MatrixStack matrices, VertexConsumer vertexConsumer, Vec3d v1, Vec3d v2, Vec3d v3, QuadColor quadColor) { int[] color = quadColor.getAllColors(); @@ -181,7 +194,7 @@ public static void vertexLine(MatrixStack matrices, VertexConsumer vertexConsume Vector3f normalVec = getNormal(x1, y1, z1, x2, y2, z2); int[] color1 = lineColor.getColor(x1, y1, z1, 0); - int[] color2 = lineColor.getColor(x2, y2, z2, 1); + int[] color2 = lineColor.getColor(x2, y2, z2, 2); vertexConsumer.vertex(model, x1, y1, z1).color(color1[0], color1[1], color1[2], color1[3]).normal(normal, normalVec.x(), normalVec.y(), normalVec.z()).next(); vertexConsumer.vertex(model, x2, y2, z2).color(color2[0], color2[1], color2[2], color2[3]).normal(normal, normalVec.x(), normalVec.y(), normalVec.z()).next(); @@ -195,5 +208,4 @@ public static Vector3f getNormal(float x1, float y1, float z1, float x2, float y return new Vector3f(xNormal / normalSqrt, yNormal / normalSqrt, zNormal / normalSqrt); } - }