Beta
Readonly
Beta
blockReadonly
Beta
isReadonly
Beta
typeStatic
Readonly
Beta
componentBeta
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.
Beta
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.
const signLocation: Vector3 = { x: 0, y: -60, z: 0 }; // Replace with your sign's coordinates
const block = world.getDimension("overworld").getBlock(signLocation);
if (!block) {
world.sendMessage("Could not find a block at specified location.");
return;
}
const sign = block.getComponent("minecraft:sign") as BlockSignComponent;
const helloWorldMessage: RawMessage = { text: "Hello World" };
sign.setText(helloWorldMessage);
// Sign text will be saved as a RawText
const result = sign.getRawText();
world.sendMessage(JSON.stringify(result)); // { rawtext: [{ text: 'Hello World' }] };
const signLocation: Vector3 = { x: 0, y: -60, z: 0 }; // Replace with your sign's coordinates
const block = world.getDimension("overworld").getBlock(signLocation);
if (!block) {
world.sendMessage("Could not find a block at specified location.");
return;
}
const sign = block.getComponent("minecraft:sign") as BlockSignComponent;
const helloWorldText: RawText = { rawtext: [{ text: "Hello World" }] };
sign.setText(helloWorldText);
// There will be no data transformation unlike calling setText with a RawMessage
const result = sign.getRawText();
world.sendMessage(JSON.stringify(result)); // { rawtext: [{ text: 'Hello World' }] };
const signLocation: Vector3 = { x: 0, y: -60, z: 0 }; // Replace with your sign's coordinates
const block = world.getDimension("overworld").getBlock(signLocation);
if (!block) {
world.sendMessage("Could not find a block at specified location.");
return;
}
const sign = block.getComponent("minecraft:sign") as BlockSignComponent;
// Set sign to say 'Hello'
sign.setText("Hello World");
world.sendMessage(sign.getText() ?? "undefined"); // 'Hello World'
Represents a block that can display text on it.