From 317b84943afb531b64bf35ac76887c7d5b876979 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Wed, 29 Jan 2025 19:33:55 +0300 Subject: [PATCH] feat: Add block highlight color option to allow always it to be blue (useful!) --- src/optionsGuiScheme.tsx | 13 +++++++++++++ src/optionsStorage.ts | 1 + src/worldInteractions.ts | 14 +++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/optionsGuiScheme.tsx b/src/optionsGuiScheme.tsx index ef7fc1c61..eab356421 100644 --- a/src/optionsGuiScheme.tsx +++ b/src/optionsGuiScheme.tsx @@ -233,6 +233,19 @@ export const guiOptionsScheme: { chatSelect: { }, }, + { + custom () { + return World + }, + highlightBlockColor: { + text: 'Block Highlight Color', + values: [ + ['auto', 'Auto'], + ['blue', 'Blue'], + ['classic', 'Classic'] + ], + }, + }, { custom () { return Sign Editor diff --git a/src/optionsStorage.ts b/src/optionsStorage.ts index 1220baca5..cf1eccd5f 100644 --- a/src/optionsStorage.ts +++ b/src/optionsStorage.ts @@ -96,6 +96,7 @@ const defaultOptions = { displayBossBars: false, // boss bar overlay was removed for some reason, enable safely disabledUiParts: [] as string[], neighborChunkUpdates: true, + highlightBlockColor: 'auto' as 'auto' | 'blue' | 'classic', } function getDefaultTouchControlsPositions () { diff --git a/src/worldInteractions.ts b/src/worldInteractions.ts index 3c7e4fa97..b18115694 100644 --- a/src/worldInteractions.ts +++ b/src/worldInteractions.ts @@ -6,6 +6,7 @@ import * as THREE from 'three' import { Vec3 } from 'vec3' import { LineMaterial } from 'three-stdlib' import { Entity } from 'prismarine-entity' +import { subscribeKey } from 'valtio/utils' import destroyStage0 from '../assets/destroy_stage_0.png' import destroyStage1 from '../assets/destroy_stage_1.png' import destroyStage2 from '../assets/destroy_stage_2.png' @@ -149,7 +150,16 @@ class WorldInteraction { const inCreative = bot.game.gameMode === 'creative' const pixelRatio = viewer.renderer.getPixelRatio() viewer.world.threejsCursorLineMaterial = new LineMaterial({ - color: inCreative ? 0x40_80_ff : 0x00_00_00, + color: (() => { + switch (options.highlightBlockColor) { + case 'blue': + return 0x40_80_ff + case 'classic': + return 0x00_00_00 + default: + return inCreative ? 0x40_80_ff : 0x00_00_00 + } + })(), linewidth: Math.max(pixelRatio * 0.7, 1) * 2, // dashed: true, // dashSize: 5, @@ -158,6 +168,8 @@ class WorldInteraction { upLineMaterial() // todo use gamemode update only bot.on('game', upLineMaterial) + // Update material when highlight color setting changes + subscribeKey(options, 'highlightBlockColor', upLineMaterial) } activateEntity (entity: Entity) {