Skip to content

Commit d030376

Browse files
authored
Release (#433)
2 parents fb4989f + 5c905d3 commit d030376

File tree

4 files changed

+41
-16
lines changed

4 files changed

+41
-16
lines changed

src/mineflayer/mc-protocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ customEvents.on('mineflayerBotCreated', () => {
3131
}
3232

3333
const onClientError = (err, data) => {
34-
const error = new MinecraftProtocolError(`Minecraft protocol client error: ${err.message}`, err, data)
34+
const error = new MinecraftProtocolError(`Minecraft protocol client error: ${String(err)}`, err, data)
3535
reportError(error)
3636
}
3737
if (typeof bot._client['_events'].error === 'function') {

src/react/DiscordButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import PixelartIcon, { pixelartIcons } from './PixelartIcon'
77
export const DiscordButton = ({ text, style }: { text?: string, style?: Record<string, any> }) => {
88
const links: DropdownButtonItem[] = [
99
{
10-
text: 'Support Official Server (mcraft.fun)',
11-
clickHandler: () => openURL('https://discord.gg/xzGRhxtRUt')
10+
text: 'Pro Enthusiasts Server (ask for invite)',
11+
clickHandler: () => openURL('https://mcraft.fun/discord')
1212
},
1313
{
1414
text: 'Community Server (PrismarineJS)',
15-
clickHandler: () => openURL('https://discord.gg/4Ucm684Fq3')
15+
clickHandler: () => openURL('https://discord.gg/prismarinejs-413438066984747026')
1616
}
1717
]
1818

src/react/simpleHooks.ts

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,43 @@
11
import { useUtilsEffect } from '@zardoy/react-util'
22
import { useEffect, useState } from 'react'
3-
import { useMedia } from 'react-use'
43

5-
const SMALL_SCREEN_MEDIA = '@media (max-width: 440px)'
4+
const SMALL_SCREEN_WIDTH = 440
65
export const useIsSmallWidth = () => {
7-
return useMedia(SMALL_SCREEN_MEDIA.replace('@media ', ''))
6+
const [isSmall, setIsSmall] = useState(() => document.documentElement.clientWidth <= SMALL_SCREEN_WIDTH)
7+
8+
useEffect(() => {
9+
const checkWidth = () => {
10+
setIsSmall(document.documentElement.clientWidth <= SMALL_SCREEN_WIDTH)
11+
}
12+
addEventListener('resize', checkWidth)
13+
return () => {
14+
removeEventListener('resize', checkWidth)
15+
}
16+
}, [])
17+
18+
return isSmall
819
}
920

1021
export const usePassesWindowDimensions = (minWidth: number | null = null, minHeight: number | null = null) => {
11-
let media = '('
12-
if (minWidth !== null) {
13-
media += `min-width: ${minWidth}px, `
14-
}
15-
if (minHeight !== null) {
16-
media += `min-height: ${minHeight}px, `
17-
}
18-
media += ')'
19-
return useMedia(media)
22+
const [passes, setPasses] = useState(() => {
23+
const width = document.documentElement.clientWidth
24+
const height = document.documentElement.clientHeight
25+
return (minWidth === null || width >= minWidth) && (minHeight === null || height >= minHeight)
26+
})
27+
28+
useEffect(() => {
29+
const checkDimensions = () => {
30+
const width = document.documentElement.clientWidth
31+
const height = document.documentElement.clientHeight
32+
setPasses((minWidth === null || width >= minWidth) && (minHeight === null || height >= minHeight))
33+
}
34+
addEventListener('resize', checkDimensions)
35+
return () => {
36+
removeEventListener('resize', checkDimensions)
37+
}
38+
}, [minWidth, minHeight])
39+
40+
return passes
2041
}
2142

2243
export const useCopyKeybinding = (getCopyText: () => string | undefined) => {

src/styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
@import url('pixelarticons/fonts/pixelart-icons-font.css');
33

44
body {
5+
width: 100vw !important;
6+
height: 100vh !important;
57
width: 100dvw !important;
68
height: 100dvh !important;
79
}
810

911
body.rotated {
12+
width: 100vh !important;
13+
height: 100vw !important;
1014
width: 100dvh !important;
1115
height: 100dvw !important;
1216
transform: rotate(90deg) translateY(-100%);

0 commit comments

Comments
 (0)