fix: dont display hand & cursor block outline in spectator.
This commit is contained in:
parent
f76c7fb782
commit
25f2fdef4e
5 changed files with 30 additions and 4 deletions
|
|
@ -31,6 +31,8 @@ export interface IPlayerState {
|
|||
getHeldItem?(isLeftHand: boolean): HandItemBlock | undefined
|
||||
username?: string
|
||||
onlineMode?: boolean
|
||||
lightingDisabled?: boolean
|
||||
shouldHideHand?: boolean
|
||||
|
||||
events: TypedEmitter<PlayerStateEvents>
|
||||
|
||||
|
|
|
|||
|
|
@ -470,7 +470,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|||
const cam = this.camera instanceof THREE.Group ? this.camera.children.find(child => child instanceof THREE.PerspectiveCamera) as THREE.PerspectiveCamera : this.camera
|
||||
this.renderer.render(this.scene, cam)
|
||||
|
||||
if (this.displayOptions.inWorldRenderingConfig.showHand/* && !this.freeFlyMode */) {
|
||||
if (this.displayOptions.inWorldRenderingConfig.showHand && !this.playerState.shouldHideHand /* && !this.freeFlyMode */) {
|
||||
this.holdingBlock.render(this.camera, this.renderer, this.ambientLight, this.directionalLight)
|
||||
this.holdingBlockLeft.render(this.camera, this.renderer, this.ambientLight, this.directionalLight)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ export class PlayerStateManager implements IPlayerState {
|
|||
private itemUsageTicks = 0
|
||||
private isUsingItem = false
|
||||
private ready = false
|
||||
public lightingDisabled = false
|
||||
onlineMode = false
|
||||
get username () {
|
||||
return bot.username ?? ''
|
||||
|
|
@ -51,6 +52,21 @@ export class PlayerStateManager implements IPlayerState {
|
|||
}
|
||||
|
||||
private botCreated () {
|
||||
const handleDimensionData = (data) => {
|
||||
let hasSkyLight = 1
|
||||
try {
|
||||
hasSkyLight = data.dimension.value.has_skylight.value
|
||||
} catch {}
|
||||
this.lightingDisabled = bot.game.dimension === 'the_nether' || bot.game.dimension === 'the_end' || !hasSkyLight
|
||||
}
|
||||
|
||||
bot._client.on('login', (packet) => {
|
||||
handleDimensionData(packet)
|
||||
})
|
||||
bot._client.on('respawn', (packet) => {
|
||||
handleDimensionData(packet)
|
||||
})
|
||||
|
||||
// Movement tracking
|
||||
bot.on('move', this.updateState)
|
||||
|
||||
|
|
@ -75,6 +91,10 @@ export class PlayerStateManager implements IPlayerState {
|
|||
this.reactive.gameMode = bot.game?.gameMode
|
||||
}
|
||||
|
||||
get shouldHideHand () {
|
||||
return this.reactive.gameMode === 'spectator'
|
||||
}
|
||||
|
||||
// #region Movement and Physics State
|
||||
private updateState () {
|
||||
if (!bot?.entity || this.disableStateUpdates) return
|
||||
|
|
@ -118,7 +138,7 @@ export class PlayerStateManager implements IPlayerState {
|
|||
}
|
||||
|
||||
getEyeHeight (): number {
|
||||
return bot.controlState.sneak ? 1.27 : 1.62
|
||||
return bot.controlState.sneak && !this.isFlying() ? 1.27 : 1.62
|
||||
}
|
||||
|
||||
isOnGround (): boolean {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { sendVideoInteraction, videoCursorInteraction } from '../../customChanne
|
|||
|
||||
function cursorBlockDisplay (bot: Bot) {
|
||||
const updateCursorBlock = (data?: { block: Block }) => {
|
||||
if (!data?.block) {
|
||||
if (!data?.block || bot.game.gameMode === 'spectator') {
|
||||
playerState.reactive.lookingAtBlock = undefined
|
||||
return
|
||||
}
|
||||
|
|
@ -27,6 +27,10 @@ function cursorBlockDisplay (bot: Bot) {
|
|||
}
|
||||
|
||||
bot.on('highlightCursorBlock', updateCursorBlock)
|
||||
bot.on('game', () => {
|
||||
const block = bot.mouse.getCursorState().cursorBlock
|
||||
updateCursorBlock(block ? { block } : undefined)
|
||||
})
|
||||
|
||||
bot.on('blockBreakProgressStage', (block, stage) => {
|
||||
const mergedShape = bot.mouse.getMergedCursorShape(block)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ const Inner = () => {
|
|||
state,
|
||||
lines: [String(chunk?.loads.length ?? 0)],
|
||||
sidebarLines: [
|
||||
`loads: ${chunk.loads.map(l => `${l.reason} ${l.dataLength} ${l.time}`).join('\n')}`,
|
||||
`loads: ${chunk.loads?.map(l => `${l.reason} ${l.dataLength} ${l.time}`).join('\n')}`,
|
||||
// `blockUpdates: ${chunk.blockUpdates}`,
|
||||
],
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue