Readonly
buttonReadonly
entityReadonly
entityimport { world } from "@minecraft/server";
const healthChangedSubscription =
world.afterEvents.entityHealthChanged.subscribe(
(event) => {
console.log("Entity:", event.entity);
console.log("Old Health:", event.oldValue);
console.log("New Health:", event.newValue);
// Your custom handling for entity health change event
// Example: Display a message, update UI, etc.
},
{
// Optionally provide EntityEventOptions to filter entities or entity types
entities: [],
entityTypes: ["minecraft:player", "minecraft:zombie"], // Array of entity type IDs
}
);
// Later, you can unsubscribe when needed
world.afterEvents.entityHealthChanged.unsubscribe(healthChangedSubscription);
Readonly
entityimport { world } from "@minecraft/server";
world.afterEvents.entityHitEntity.subscribe((event) => {
const location1 = event.damagingEntity.location;
const location2 = event.hitEntity.location;
const distance = Math.pow(
Math.pow(location2.x - location1.x, 2) +
Math.pow(location2.y - location1.y, 2) +
Math.pow(location2.z - location1.z, 2),
0.5
);
console.log("Distance: " + distance + " blocks");
});
Readonly
entityimport { world } from "@minecraft/server";
world.afterEvents.entityHitBlock.subscribe((event) => {
const location1 = event.damagingEntity.location;
const location2 = event.hitBlock.location;
const distance = Math.pow(
Math.pow(location2.x - location1.x, 2) +
Math.pow(location2.y - location1.y, 2) +
Math.pow(location2.z - location1.z, 2),
0.5
);
console.log("Distance: " + distance + " blocks");
});
Readonly
entityReadonly
itemReadonly
itemReadonly
itemReadonly
itemReadonly
itemReadonly
itemReadonly
itemReadonly
itemReadonly
leverReadonly
playerReadonly
playerReadonly
playerReadonly
pressureReadonly
pressureReadonly
projectileReadonly
projectileReadonly
targetReadonly
trip
Contains a set of events that are available across the scope of the World.