Skip to content

Commit

Permalink
feat: Add block highlight color option to allow always it to be blue …
Browse files Browse the repository at this point in the history
…(useful!)
  • Loading branch information
zardoy committed Jan 29, 2025
1 parent 2490fbe commit 317b849
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/optionsGuiScheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ export const guiOptionsScheme: {
chatSelect: {
},
},
{
custom () {
return <Category>World</Category>
},
highlightBlockColor: {
text: 'Block Highlight Color',
values: [
['auto', 'Auto'],
['blue', 'Blue'],
['classic', 'Classic']
],
},
},
{
custom () {
return <Category>Sign Editor</Category>
Expand Down
1 change: 1 addition & 0 deletions src/optionsStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
14 changes: 13 additions & 1 deletion src/worldInteractions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand Down

0 comments on commit 317b849

Please sign in to comment.