#custom component not registering
1 messages · Page 1 of 1 (latest)
Errors
[Scripting][warning]-slowness.js loaded
[Scripting][warning]-main.js loaded
[Scripting][error]-TypeError: must be called with new at BlockComponentRegistry (native)
at <anonymous> (custom_components/slowness.js:10)
can somone help please
onApply does not exist
import { world } from '@minecraft/server';
const slownessComponent = {
onPlace(data) {
console.warn('Slowness component applied!');
}
}
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }) => {
blockComponentRegistry.registerCustomComponent('bshy:slowness', slownessComponent);
});
@fair pike can i ask you a question
so ive changed it to onStepOn and it works with a full collision box, but my block has no collison box and is till want it to work is that still possible
I don't think it's possible, you can use onTick to constantly check if there is an entity at the block location
const slownessComponent = {
onTick({ block }) {
const entities = block.dimension.getEntitiesAtBlockLocation(block.location);
if (entities.length === 0) return;
entities.forEach((entity) => {
entity.addEffect('slowness', 10 * 20, { amplifier: 0, showParticles: true });
});
}
}
@fair pike can you only change block states with scripts ?