I am currently using Node.js with yo
and gulp
to create a behavior pack with scripts. I’m struggling to find a proper list of all the API events online so I was hoping someone here could help me with them. I’ve been trying to find the identifier for the event that occurs when a chat message is sent.
My code:
var clientSystem = client.registerSystem(0, 0);
// Setup which events to listen for
clientSystem.initialize = function () {
// Register any events you will send to the client
const eventDataDefaults = {narf: false}
clientSystem.registerEventData("test:pinky", eventDataDefaults)
clientSystem.listenForEvent("minecraft:chat_broadcast_event", (eventData) => {
eventData.message = `${eventData.sender.name} sent a message!`;
});
// Register any components you will attach to game objects
// system.registerComponent(...)
// Set up any events you wish to listen to
// system.listenForEvent(...);
// Enable full logging, useful for seeing errors, you will probably want to disable this for
// release versions of your scripts.
// Generally speaking it's not recommended to use broadcastEvent in initialize, but for configuring logging it's fine.
const scriptLoggerConfig = clientSystem.createEventData("minecraft:script_logger_config");
scriptLoggerConfig.data.log_errors = true;
scriptLoggerConfig.data.log_information = true;
scriptLoggerConfig.data.log_warnings = true;
clientSystem.broadcastEvent("minecraft:script_logger_config", scriptLoggerConfig);
}
let firstTick = true;
let ticks = 0;
let seconds = 0;
// per-tick updates
clientSystem.update = function() {
// Any logic that needs to happen every tick on the client.
ticks++;
seconds = Math.floor(ticks / 20);
if(ticks % 20 === 0) {
let uptime = clientSystem.createEventData("minecraft:display_chat_event");
uptime.data.message = `Uptime: ${seconds} seconds`;
clientSystem.broadcastEvent("minecraft:display_chat_event", uptime);
}