Add online_mode and velocity_secret config options
Some checks failed
Build JStom / build (push) Failing after 53s
Some checks failed
Build JStom / build (push) Failing after 53s
This commit is contained in:
25
scripts/elytra_spawn.js
Normal file
25
scripts/elytra_spawn.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const ItemStack = Java.type('net.minestom.server.item.ItemStack');
|
||||
const Material = Java.type('net.minestom.server.item.Material');
|
||||
const EquipmentSlot = Java.type('net.minestom.server.entity.EquipmentSlot');
|
||||
const DataComponents = Java.type('net.minestom.server.component.DataComponents');
|
||||
const FireworkList = Java.type('net.minestom.server.item.component.FireworkList');
|
||||
|
||||
server.log("Elytra script loaded!");
|
||||
|
||||
server.on('net.minestom.server.event.player.PlayerSpawnEvent', (event) => {
|
||||
const player = event.getPlayer();
|
||||
|
||||
// Create items using fromKey (safer than static field access)
|
||||
const elytra = ItemStack.of(Material.fromKey("minecraft:elytra"));
|
||||
|
||||
// Create fireworks with flight duration 3
|
||||
var fireworks = ItemStack.of(Material.fromKey("minecraft:firework_rocket"))
|
||||
.withAmount(64)
|
||||
.with(DataComponents.FIREWORKS, FireworkList.EMPTY.withFlightDuration(3));
|
||||
|
||||
// Equip items
|
||||
player.setEquipment(EquipmentSlot.CHESTPLATE, elytra);
|
||||
player.setEquipment(EquipmentSlot.OFF_HAND, fireworks);
|
||||
|
||||
player.sendMessage("You have been equipped with an Elytra and Fireworks (Flight Duration 3)!");
|
||||
});
|
||||
Reference in New Issue
Block a user