-
Notifications
You must be signed in to change notification settings - Fork 2
/
示例.txt
29 lines (24 loc) · 1.15 KB
/
示例.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function onUse(event) {
var sf = "creeper_spawn_egg{EntityTag:{id:\"minecraft:iron_golem\"}}"; // 材质+铁傀儡
var player = event.getPlayer();
var inv = player.getInventory();
var itemInMainHand = inv.getItemInMainHand();
if (itemInMainHand != null && itemInMainHand.getAmount() > 0) {
var amount = itemInMainHand.getAmount();
itemInMainHand.setAmount(0);
runOpCommand(player, "give " + player.getName() + " " + sf + " " + amount);
}
}
上面的是右键不会消耗
function onUse(event) {
var mob = "creeper_spawn_egg{EntityTag:{id:\"minecraft:iron_golem\"}}"; // 材质+铁傀儡
var player = event.getPlayer();
var inv = player.getInventory();
var itemInMainHand = inv.getItemInMainHand();
if (itemInMainHand != null && itemInMainHand.getAmount() > 0) {
var amount = itemInMainHand.getAmount();
itemInMainHand.setAmount(itemInMainHand.getAmount() - 1);
runOpCommand(player, "give " + player.getName() + " " + mob + " " + amount);
}
}
指令中id后的/"代表转义,因为外面还有一层双引号,双引号内的所有双引号都得用/"