Skip to content

Commit a7107e5

Browse files
Examples
1 parent 916aabd commit a7107e5

31 files changed

Lines changed: 204 additions & 4 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const damageApplied = entity.applyDamage(10);
2+
console.log(`Damage applied: ${damageApplied}`);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const blockHit = entity.getBlockFromViewDirection();
2+
3+
if (blockHit) {
4+
console.log("Block Hit:");
5+
console.log("Block:", blockHit.block);
6+
console.log("Face:", blockHit.face);
7+
console.log("Face Location:", JSON.stringify(blockHit.faceLocation));
8+
} else {
9+
console.log("No block in view direction.");
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { EntityHealthComponent, world } from "@minecraft/server";
2+
3+
for (const entity of world.getDimension('overworld').getEntities()) {
4+
const health = entity.getComponent(EntityHealthComponent.componentId) as EntityHealthComponent;
5+
entity.nameTag = health.currentValue.toString();
6+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const components = entity.getComponents();
2+
console.log(`Number of components: ${components.length}: ${components.map(component => component.typeId)}`);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
player.teleport(
2+
{ x: 0, y: 0, z: 0 },
3+
{ dimension: world.getDimension("nether") }
4+
);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
player.teleport(
2+
{ x: 0, y: 0, z: 0 },
3+
{
4+
dimension: world.getDimension("nether"),
5+
teleportFacing: { x: 100, y: 100, z: 100 },
6+
}
7+
);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const xpAdded = player.addExperience(100);
2+
console.log(`Player ${player.name} now has ${xpAdded} experience points.`);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const levels = player.addLevels(5);
2+
console.log(`Player ${player.name} now has ${levels} levels.`)
3+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const cooldown = player.getItemCooldown("equipment");
2+
console.log(`Cooldown for the equipment category: ${cooldown} seconds.`);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const spawnPoint = player.getSpawnPoint();
2+
if (spawnPoint) {
3+
console.log(`Spawn point location: ${spawnPoint.x} ${spawnPoint.y} ${spawnPoint.z} at ${spawnPoint.dimension.id}`);
4+
} else {
5+
console.log(`No spawn point set.`);
6+
}

0 commit comments

Comments
 (0)