#Blocks that Hurt Players/Mobs on Contact
1 messages · Page 1 of 1 (latest)
Something like that could work. 😉
const dimensions = ["minecraft:overworld", "minecraft:nether", "minecraft:the_end"];
for (const dimensionId of dimensions) {
const entities = world.getDimension(dimensionId).getEntities();
for (const entity of entities) {
if (!entity.isValid || !entity.getComponent("minecraft:health")) continue;
const block = world.getDimension(dimensionId).getBlock({
x: Math.floor(entity.location.x),
y: Math.floor(entity.location.y - 0.1),
z: Math.floor(entity.location.z)
});
if (block?.isValid && block.typeId == "custom_addon:my_block") {
entity.applyDamage(1, {cause: "contact"});
}
}
}
}, 10);```
Add this to the main block .json?