Files

1.9 KiB

IScriptWorld.testForBlock

← IScriptWorld · ← Master

Parça 8/16 · önceki · sonraki

var pos = c.getSubject().getPosition(); var entities = c.getWorld().getEntities(pos.x - 30, pos.y - 30, pos.z - 30, pos.x + 30, pos.y + 30, pos.z + 30, true);

for (var i in entities) { var entity = entities[i];

if (!entity.isSame(c.getSubject())) { entity.damage(2.0); } }

getEntities

java.util.List getEntities(double x, double y, double z, double radius)

Get entities within the sphere specified by given coordinates and radius in this world. This method limits to scanning entities only within 50 blocks radius in any direction. If the sphere provided has the radius that is longer than 100 blocks, then it will simply return an empty list.

var pos = c.getSubject().getPosition(); var entities = c.getWorld().getEntities(pos.x, pos.y + 1, pos.z, 3);

for (var i in entities) { var entity = entities[i];

if (!entity.isSame(c.getSubject())) { entity.damage(2.0); } }

playSound

default void playSound(java.lang.String event, double x, double y, double z)

Play a sound event in the world.

For all possible sound event IDs, please refer to either /playsound command, or script editor's sound picker.

var pos = c.getSubject().getPosition();

c.getWorld().playSound("minecraft:entity.pig.ambient", pos.x, pos.y, pos.z);

playSound

void playSound(java.lang.String event, double x, double y, double z, float volume, float pitch)

Play a sound event in the world with volume and pitch.

var pos = c.getSubject().getPosition();

c.getWorld().playSound("minecraft:entity.pig.ambient", pos.x, pos.y, pos.z, 1.0, 0.8);

stopAllSounds

default void stopAllSounds()

Stop all playing sound events for every player.