#scriptAPI
1 messages · Page 1 of 1 (latest)
import { world,system } from "@minecraft/server";
import { ModalFormData,ActionFormData,MessageFormData } from "@minecraft/server-ui"
// 防具立てを取得しておく
const armorStand = <Entity>;
// 防具立ての2ブロック上のドロッパーを取得
// 取得したブロックが無効なら処理を抜ける
// 取得したブロックがドロッパーでは無いとき処理を抜ける
const dropper = armorStand.dimension.getBlock({
x: armorStand.location.x,
y: armorStand.location.y + 2,
z: armorStand.location.z
});
if (!dropper?.isValid()) return;
if (dropper.typeId !== "minecraft:dropper") return;
// ドロッパーからコンテナを取得
// コンテナが無効なら抜ける
const dropperContainer = dropper.getComponent("inventory")?.container;
if (!dropperContainer?.isValid()) return;
const chest = <Dimension>.getBlock({ x: 0, y: -60, z: 0 });
if (!chest?.isValid()) return;
if (chest.typeId !== "minecraft:chest") return;
const chestContainer = chest.getComponent("inventory")?.container;
if (!chestContainer?.isValid()) return;
for (let chestSlot = 0; chestSlot < chestContainer.size; chestSlot += 1) {
// チェストのコンテナから順番にアイテムを取得
// アイテムがない場合は次へ
const chestItem = chestContainer.getItem(chestSlot);
if (!chestItem) continue;
for (let dropperSlot = 0; dropperSlot < dropperContainer.size; dropperSlot += 1) {
const dropperItem = dropperContainer.getItem(dropperSlot);
// ひとつでも入っていたら
if (chestItemとdropperItemを比較) {
// コマンド実行
return;
}
}
}
importはこれで会ってますか
あと
エンティティの部分に何を入れたらいいですか
調べても出てこなくて
どのアーマースタンドに対して実行したいか、数は複数かどうかを教えてください
鍵付きドア(ドロッパーを使った)(複数)が作りたいです
処理の流れ
タグaのついたアーマースタンドの3つ上のドロッパーの中に
0,-60,0のチェストに入っているアイテムが一つでも入っていたらコマンド実行
あと、scriptAPIって何を見て作ってるんですか
jsは大体理解出来ました
これの見方がわかりません
どこを見ればいいかが
鍵付きドア(ドロッパーを使った)(複数)が作りたいです
処理の流れ
タグaのついたアーマースタンドの3つ上のドロッパーの中に
0,-60,0のチェストに入っているアイテムが一つでも入っていたらコマンド実行
上にも書いてる通り
getEntity('minecraft:armor_stand').hasTag('a')これでよくないですか
そうやって使うんですね!
<World>.getEntityはエンティティのidを必要とします<Dimension>.getEntitiesを使ってください
見方については各クラスごとにプロパティとメソッドが並んでいるのでその辺が分かっていれば読めると思います
出ないままやるか出るようにするかのどちらかが考えられますね。
// ひとつでも入っていたら
if (chestItemとdropperItemを比較) {
// コマンド実行
return;
}
}
}
ここの日本語の部分、何書けばいいですか