Skip to content

Commit

Permalink
Add highlight color as config option
Browse files Browse the repository at this point in the history
  • Loading branch information
RedVortexDev committed Aug 1, 2023
1 parent 553e589 commit ad46f3c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
22 changes: 17 additions & 5 deletions src/main/java/dev/dfonline/codeclient/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import dev.dfonline.codeclient.FileManager;
import dev.dfonline.codeclient.hypercube.actiondump.ActionDump;
import dev.isxander.yacl3.api.*;
import dev.isxander.yacl3.api.controller.FloatSliderControllerBuilder;
import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder;
import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder;
import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder;
import dev.isxander.yacl3.api.controller.*;
import dev.isxander.yacl3.gui.controllers.ColorController;
import dev.isxander.yacl3.gui.controllers.cycling.EnumController;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

import java.awt.*;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

Expand All @@ -38,6 +37,7 @@ public class Config {
public boolean FocusSearch = false;
public CharSetOption SaveCharSet = CharSetOption.UTF_8;
public boolean RecentChestInsert = true;
public Color ChestHighlightColor = new Color(0.2F, 1.0F, 1.0F);

private void save() {
try {
Expand Down Expand Up @@ -294,12 +294,24 @@ public YetAnotherConfigLib getLibConfig() {
.text(Text.literal("Highlights the chest you inserted (left-clicked) an item into"))
.build())
.binding(
false,
true,
() -> RecentChestInsert,
opt -> RecentChestInsert = opt
)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(Color.class)
.name(Text.literal("Recent Inserted Chest Highlight Color"))
.description(OptionDescription.createBuilder()
.text(Text.literal("Color of chest highlight"))
.build())
.binding(
new Color(0.2F, 1.0F, 1.0F),
() -> ChestHighlightColor,
opt -> ChestHighlightColor = opt
)
.controller(ColorControllerBuilder::create)
.build())
.option(Option.createBuilder(Boolean.class)
.name(Text.literal("Show Invisible Blocks"))
.description(OptionDescription.createBuilder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.dfonline.codeclient.dev;

import dev.dfonline.codeclient.CodeClient;
import dev.dfonline.codeclient.config.Config;
import dev.dfonline.codeclient.location.Dev;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
Expand All @@ -10,6 +11,8 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;

import java.awt.*;

public class RecentChestInsert {
private static float alpha = 0;
private static BlockPos lastChest = null;
Expand All @@ -23,7 +26,8 @@ public static void render(MatrixStack matrices, VertexConsumerProvider.Immediate
if(lastChest == null) return;
VoxelShape shape = CodeClient.MC.world.getBlockState(lastChest).getOutlineShape(CodeClient.MC.world, lastChest).offset(lastChest.getX(),lastChest.getY(),lastChest.getZ());
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getLines());
WorldRenderer.drawShapeOutline(matrices, vertexConsumer, shape, -cameraX, -cameraY, -cameraZ, 0.2F, 1.0F, 1.0F, Math.min(alpha,1), true);
Color color = Config.getConfig().ChestHighlightColor;
WorldRenderer.drawShapeOutline(matrices, vertexConsumer, shape, -cameraX, -cameraY, -cameraZ, (float) color.getRed() / 255, (float) color.getGreen() / 255, (float) color.getBlue() / 255, Math.min(alpha,1), true);
}
}

Expand Down

0 comments on commit ad46f3c

Please sign in to comment.