feat: add CN support for block info
Build & Publish Bedrock Addon / publish (release) Has been cancelled

This commit is contained in:
2026-06-19 21:57:58 +08:00
Unverified
parent 735d585400
commit e2337591b8
2 changed files with 875 additions and 3 deletions
+15 -3
View File
@@ -1,7 +1,7 @@
import { GameMode, system, world } from '@minecraft/server';
import { Raycaster } from '../classes/Raycaster';
import { fetchMatchingItemSlot } from '../utils';
import { Block_state, chinese_text, State_values } from './zhMappings';
class BlockInfo {
static shownToLastTick = new Set();
@@ -41,7 +41,12 @@ class BlockInfo {
static getBlockMessage(block) {
if (!block)
return { translate: 'construct.blockinfo.unknown' };
const message = { rawtext: [{ text: '§a' }, { translate: block.localizationKey }] };
const message = { rawtext: [{ text: '§a' }]};
if (chinese_text[block.type.id] !== undefined) {
message.rawtext.push({ text: chinese_text[block.type.id] });
} else {
message.rawtext.push({ translate: block.localizationKey });
}
const states = block.getAllStates();
if (Object.keys(states).length > 0)
message.rawtext.push({ text: `\n§7${this.getFormattedStates(states)}` });
@@ -55,7 +60,14 @@ class BlockInfo {
}
static getFormattedStates(states) {
return Object.entries(states).map(([key, value]) => `§7${key}: §3${value}`).join('\n');
return Object.entries(states)
.map(([stateName, stateValue]) => {
if (State_values[stateName] || Block_state[stateName]) {
return (`\n§7${Block_state[stateName]}`)
.replaceAll('%1', `§3${State_values[stateName][String(stateValue)]}§7`);
}
})
.join('');
}
static getSupplyMessage(player, block) {