Readonly
blockReadonly
isReadonly
typeStatic
Readonly
componentThe message to set on the sign. If set to a string, then
call getText
to read that string. If set to a RawMessage,
then calling getRawText
will return a RawText. If set to a
RawText, then calling getRawText
will return the same
object that was passed in.
Optional
side: SignSideThe side of the sign the message will be set on. If not provided, the message will be set on the front side of the sign.
import {
BlockComponentTypes,
DimensionLocation,
RawMessage,
RawText,
} from '@minecraft/server';
// Function which updates a sign blocks text to raw text
function updateSignText(signLocation: DimensionLocation) {
const block = signLocation.dimension.getBlock(signLocation);
if (!block) {
console.warn('Could not find a block at specified location.');
return;
}
const sign = block.getComponent(BlockComponentTypes.Sign);
if (sign) {
// RawMessage
const helloWorldMessage: RawMessage = { text: 'Hello World' };
sign.setText(helloWorldMessage);
// RawText
const helloWorldText: RawText = { rawtext: [{ text: 'Hello World' }] };
sign.setText(helloWorldText);
// Regular string
sign.setText('Hello World');
} else {
console.warn('Could not find a sign component on the block.');
}
}
Represents a block that can display text on it.
Example: addTwoSidedSign.ts
Example: setSignText.ts
Example: createTranslatedSign.ts