Private
constructorReadonly
blockBlock instance that this component pertains to.
Readonly
isWhether or not players can edit the sign. This happens if a
sign has had a honeycomb used on it or setWaxed
was called
on the sign.
This property can throw when used.
Readonly
typeIdentifier of the component.
Static
Readonly
componentOptional
side: SignSideThe side of the sign to read the message from. If not provided, this will return the message from the front side of the sign.
Optional
Returns the RawText of the sign if setText
was called with
a RawMessage or a RawText object, otherwise returns
undefined.
This function can throw errors.
Optional
side: SignSideThe side of the sign to read the message from. If not provided, this will return the message from the front side of the sign.
Optional
Returns the text of the sign if setText
was called with a
string, otherwise returns undefined.
This function can throw errors.
Optional
side: SignSideThe side of the sign to read the dye from. If not provided, this will return the dye on the front side of the sign.
Optional
Gets the dye that is on the text or undefined if the sign has not been dyed.
This function can throw errors.
The 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.
Optional
Sets the text of the sign component.
This function can't be called in read-only mode.
Throws if the provided message is greater than 512 characters in length.
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