#Particle Block outline
1 messages · Page 1 of 1 (latest)
i want to do something where when i place a block there is an outline of particle around the block
this is the script i have:
import { world } from "@minecraft/server";
const PARTICLE_TYPE = "minecraft:happy_villager"; //
function createOutlineParticles(blockLocation) {
const { x, y, z } = blockLocation;
const edges = [
{ x1: x, y1: y, z1: z, x2: x + 1, y2: y, z2: z },
{ x1: x, y1: y, z1: z, x2: x, y2: y + 1, z2: z },
{ x1: x, y1: y, z1: z, x2: x, y2: y, z2: z + 1 },
{ x1: x + 1, y1: y, z1: z, x2: x + 1, y2: y + 1, z2: z },
{ x1: x + 1, y1: y, z1: z, x2: x + 1, y2: y, z2: z + 1 },
{ x1: x, y1: y + 1, z1: z, x2: x + 1, y2: y + 1, z2: z },
{ x1: x, y1: y + 1, z1: z, x2: x, y2: y + 1, z2: z + 1 },
{ x1: x + 1, y1: y + 1, z1: z, x2: x + 1, y2: y + 1, z2: z + 1 },
{ x1: x + 1, y1: y + 1, z1: z, x2: x, y2: y + 1, z2: z + 1 },
{ x1: x, y1: y, z1: z + 1, x2: x + 1, y2: y, z2: z + 1 },
{ x1: x, y1: y, z1: z + 1, x2: x, y2: y + 1, z2: z + 1 },
{ x1: x + 1, y1: y, z1: z + 1, x2: x + 1, y2: y + 1, z2: z + 1 },
{ x1: x + 1, y1: y, z1: z + 1, x2: x, y2: y + 1, z2: z + 1 }
];
edges.forEach(edge => {
// Erzeuge Partikel entlang der Kanten
for (let i = 0; i <= 1; i += 0.2) {
const px = edge.x1 * (1 - i) + edge.x2 * i;
const py = edge.y1 * (1 - i) + edge.y2 * i;
const pz = edge.z1 * (1 - i) + edge.z2 * i;
// Erzeuge Partikel
world.getDimension("overworld").spawnParticle(PARTICLE_TYPE, px, py, pz);
}
});
}
// Event-Handler für das Platzieren von Blöcken
world.afterEvents.playerPlaceBlock.subscribe(event => {
const block = event.block;
const blockLocation = block.location;
// Partikel-Outline um den Block erzeugen
createOutlineParticles(blockLocation);
});
world.afterEvents.playerBreakBlock.subscribe(event => {
const blockLocation = event.block.location;
// Optional: Hier kannst du Partikel entfernen oder ändern, wenn gewünscht
});
i have no idea if the script is correct at all
the error i get:
[Scripting][error]-TypeError: Incorrect number of arguments to function. Expected 2-3, received 4 at <anonymous> (main.js:49)
at forEach (native)
at createOutlineParticles (main.js:51)
at <anonymous> (main.js:60)
I haven't checked any of the other logic, but I can say why you are getting that error. spawnParticle here takes two arguments: An ID, and a location expressed as a Vec3.
world.getDimension("overworld").spawnParticle(PARTICLE_TYPE, {x: px, y: py, z: pz});
inefficient way of doing it
this is 6 particles (one for each face)
btw this is not a help channel
But it is? This is #1067535382285135923, marked as a Question, and evidently asking about an error
this is a help channel
sorry my bad
i thought this is the resource channel
@humble scarab
the "controller" one is the one to spawn
make an outline texture
wrong ping
@polar pulsar
but i would like to have it via script and not some extra particle.json
alr
fix this then
i have already done this and i did not get an error message but also no particles
pls help
@vast sage , @acoustic pier ||(sorry for ping)||