From 025d9b4f72facbd05a38f03235483ef500577929 Mon Sep 17 00:00:00 2001 From: oasoby <134684352+oasoby@users.noreply.github.com> Date: Sun, 3 Nov 2024 18:04:13 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AE=E6=9C=80?= =?UTF-8?q?=E9=81=A9=E5=8C=96=E5=8F=8A=E3=81=B3=E3=80=81NoteStick=E3=81=AE?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/note/toggle.mcfunction | 1 + functions/note/version.mcfunction | 1 + items/note_stick.json | 25 -- manifest.json | 12 +- package-lock.json | 16 +- package.json | 4 +- scripts/main.js | 411 ++++++++++++++---------------- 7 files changed, 209 insertions(+), 261 deletions(-) create mode 100644 functions/note/toggle.mcfunction create mode 100644 functions/note/version.mcfunction delete mode 100644 items/note_stick.json diff --git a/functions/note/toggle.mcfunction b/functions/note/toggle.mcfunction new file mode 100644 index 0000000..189f553 --- /dev/null +++ b/functions/note/toggle.mcfunction @@ -0,0 +1 @@ +execute as @s run scriptevent note:toggle \ No newline at end of file diff --git a/functions/note/version.mcfunction b/functions/note/version.mcfunction new file mode 100644 index 0000000..c85b2ba --- /dev/null +++ b/functions/note/version.mcfunction @@ -0,0 +1 @@ +execute as @s run scriptevent note:version \ No newline at end of file diff --git a/items/note_stick.json b/items/note_stick.json deleted file mode 100644 index 8ee4fd0..0000000 --- a/items/note_stick.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "format_version": "1.21.0", - "minecraft:item": { - "description": { - "identifier": "note:note_stick", - "menu_category": { - "category": "equipment" - } - }, - "components": { - "minecraft:glint": true, - "minecraft:icon": { - "textures": { - "default": "stick" - } - }, - "minecraft:max_stack_size": 1, - "minecraft:display_name": { - "value": "§dnote stick" - }, - "minecraft:can_destroy_in_creative": false, - "minecraft:interact_button": true - } - } -} \ No newline at end of file diff --git a/manifest.json b/manifest.json index 22251d7..711c601 100644 --- a/manifest.json +++ b/manifest.json @@ -1,18 +1,18 @@ { "format_version": 2, "header": { - "name": "Note Block+ v1.1.3", - "description": "音ブロックの音階を表示します。", + "name": "Note Block+ v1.1.4", + "description": "音ブロックの音階を表示するアドオン。 \nTwitter:@oasoby", "min_engine_version": [ 1, 21, - 30 + 40 ], "uuid": "fc863469-2162-461d-8ba8-2691c9197deb", "version": [ 1, 1, - 3 + 4 ] }, "modules": [ @@ -40,11 +40,11 @@ "dependencies": [ { "module_name": "@minecraft/server", - "version": "2.0.0-alpha" + "version": "1.16.0-beta" }, { "module_name": "@minecraft/server-ui", - "version": "2.0.0-alpha" + "version": "1.4.0-beta" } ] } diff --git a/package-lock.json b/package-lock.json index 2467b0f..461e5db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@minecraft/server": "^1.15.0-beta.1.21.30-stable", - "@minecraft/server-ui": "^1.4.0-beta.1.21.30-stable", + "@minecraft/server": "^1.16.0-beta.1.21.44-stable", + "@minecraft/server-ui": "^1.4.0-beta.1.21.44-stable", "i": "^0.3.7", "npm": "^10.5.2" } @@ -21,17 +21,17 @@ "integrity": "sha512-JdmEq4P3Z/FtoBzhLijFgMSVFnFRrUoLwY8DHHrgtFo0mfLTOLTB1RErYjLMsA6b7BGVNxkX/pfFRiH7QZ0XwQ==" }, "node_modules/@minecraft/server": { - "version": "1.15.0-beta.1.21.30-stable", - "resolved": "https://registry.npmjs.org/@minecraft/server/-/server-1.15.0-beta.1.21.30-stable.tgz", - "integrity": "sha512-t9NhnP2W+7agojr5IWXZnC4uy9SGfcIrSFEqvNxj/NaT29/DXtH+1nJq7wLa5kGwyBlG/lDz6/CpiWn4PBv+Kg==", + "version": "1.16.0-beta.1.21.44-stable", + "resolved": "https://registry.npmjs.org/@minecraft/server/-/server-1.16.0-beta.1.21.44-stable.tgz", + "integrity": "sha512-gxH7KmEB+VLVa1eiQp83N2UYXsCKkG2zz8j9Ul/d7pqaPE9I1DnGm6KtBig6NRS/U/nu2xwUjiAUhhofB6Rsmw==", "dependencies": { "@minecraft/common": "^1.1.0" } }, "node_modules/@minecraft/server-ui": { - "version": "1.4.0-beta.1.21.30-stable", - "resolved": "https://registry.npmjs.org/@minecraft/server-ui/-/server-ui-1.4.0-beta.1.21.30-stable.tgz", - "integrity": "sha512-Ky3X8vnQnAZ43CciWvSvTjxThir46mGjq87FJzSGicdQEG2YlyAMygdxOnce3BBuPUTsEUGcEdFbnNGE4LinmQ==", + "version": "1.4.0-beta.1.21.44-stable", + "resolved": "https://registry.npmjs.org/@minecraft/server-ui/-/server-ui-1.4.0-beta.1.21.44-stable.tgz", + "integrity": "sha512-eBlGyeTVd4mP6pSN1fzepUxf9hC9dnjV0daQrdzvxLKUaKYHIaod8txqroh1TZxoMGUavTG/dTzdxJczzanluA==", "dependencies": { "@minecraft/common": "^1.0.0", "@minecraft/server": "^1.8.0" diff --git a/package.json b/package.json index 2023d7d..72ec448 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "author": "", "license": "ISC", "dependencies": { - "@minecraft/server": "^1.15.0-beta.1.21.30-stable", - "@minecraft/server-ui": "^1.4.0-beta.1.21.30-stable", + "@minecraft/server": "^1.16.0-beta.1.21.44-stable", + "@minecraft/server-ui": "^1.4.0-beta.1.21.44-stable", "i": "^0.3.7", "npm": "^10.5.2" } diff --git a/scripts/main.js b/scripts/main.js index 7cf2b62..4f1b63d 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -1,31 +1,32 @@ -import { BlockVolume, Player, system, world } from "@minecraft/server"; +import { Block, BlockType, BlockTypes, BlockVolume, Player, system, world } from "@minecraft/server"; import { ModalFormData } from "@minecraft/server-ui"; const DefaultConfig = { scale_notation: 1, - show_instrument: true, - show_click_count: true, + is_display_instrument: true, + is_display_click_count: true, language: 0 } world.afterEvents.playerSpawn.subscribe(e => { - if (e.initialSpawn) { - if (e.player.getDynamicProperty("language") == undefined) { - e.player.setDynamicProperty("language", DefaultConfig.language); - } - if (e.player.getDynamicProperty("scale_notation") == undefined) { - e.player.setDynamicProperty("scale_notation", DefaultConfig.scale_notation); - } - if (e.player.getDynamicProperty("show_instrument") == undefined) { - e.player.setDynamicProperty("show_instrument", DefaultConfig.show_instrument); - } - if (e.player.getDynamicProperty("show_click_count") == undefined) { - e.player.setDynamicProperty("show_click_count", DefaultConfig.show_click_count); - } + if (e.initialSpawn) { } + if (e.player.getDynamicProperty("language") == undefined) { + e.player.setDynamicProperty("language", DefaultConfig.language); + } + if (e.player.getDynamicProperty("scale_notation") == undefined) { + e.player.setDynamicProperty("scale_notation", DefaultConfig.scale_notation); + } + if (e.player.getDynamicProperty("is_display_instrument") == undefined) { + e.player.setDynamicProperty("is_display_instrument", DefaultConfig.is_display_instrument); + } + if (e.player.getDynamicProperty("is_display_click_count") == undefined) { + e.player.setDynamicProperty("is_display_click_count", DefaultConfig.is_display_click_count); + } + if (e.player.getDynamicProperty("isEnable") == undefined) { + sourceEntity.setDynamicProperty("isEnable", true); } }) - const scales = { international: [ "F#", @@ -55,7 +56,7 @@ const scales = { "F#" ], solfege: { - english: [ + en: [ "Fa#", "Sol", "Sol#", @@ -82,7 +83,7 @@ const scales = { "Fa", "Fa#" ], - japanese: [ + ja: [ "ファ#", "ソ", "ソ#", @@ -112,224 +113,186 @@ const scales = { } } -const instruments = { - japanese: { - "lit_pumpkin": "ピアノ", //上書き回避用 - "carved_pumpkin": "ピアノ", //上書き回避用 - "redstone_block": "ピアノ", //上書き回避用 - "_leaves": "ピアノ", //葉系 - "note_block": "バス", - "bookshelf": "バス", - "oak": "バス", //オークの木材系 - "spruce": "バス", //トウヒ系 - "birch": "バス", //樺系 - "jungle": "バス", //ジャングル系 - "acacia": "バス", //アカシア系 - "dark_oak": "バス", //ダークオーク系 - "cherry": "バス", //桜系 - "bamboo": "バス", //竹系 - "crimson": "バス", //クリムゾン系 - "warped": "バス", //歪んだ系 - "mangrove": "バス", //マングローブ系 - "chest": "バス", //チェスト系 - "crafting_table": "バス", - "jukebox": "バス", - "mushroom": "バス", //キノコ系 - "banner": "バス", //旗系 - "daylight_detector": "バス", - "loom": "バス", - "barrel": "バス", - "cartography_table": "バス", - "lectern": "バス", - "smithing_table": "バス", - "fletching_table": "バス", - "campfire": "バス", //焚き火系 - "composter": "バス", - "bee_nest": "バス", - "beehive": "バス", - "amethyst_block": "バスドラム", //アメジスト系 - "soul_sand": "カウベル", - "glass": "スティック", //ガラス系 - "sea_lantern": "スティック", - "beacon": "スティック", - "infested_": "フルート", //虫食いブロック系 - "glowstone": "電子ピアノ", - "stone": "バスドラム", //石系 - "andesite": "バスドラム", //安山岩系 - "granite": "バスドラム", //花崗岩系 - "diorite": "バスドラム", //閃緑岩系 - "basalt": "バスドラム", //玄武岩系 - "calcite": "バスドラム", - "purpur": "バスドラム", //プルプァ系 - "terracotta": "バスドラム", //色付き、彩釉テラコッタ系 - "quartz": "バスドラム", //クォーツブロック系 - "tuff": "バスドラム", //凝灰岩系 - "blackstone": "バスドラム", //ブラックストーン系 - "netherrack": "バスドラム", - "nylium": "バスドラム", //ナイリウム系 - "obsidian": "バスドラム", //黒曜石系 - "sandstone": "バスドラム", //砂岩系 - "_ore": "バスドラム", //鉱石系 - "deepslate": "バスドラム", //深層岩系 - "clay": "バスドラム", - "raw_": "バスドラム", //原石ブロック系 - "brick": "バスドラム", //レンガ系 - "prismarine": "バスドラム", //プリズマリン系 - "coral": "バスドラム", //サンゴ系 - "respawn_anchor": "バスドラム", - "bedrock": "バスドラム", - "observer": "バスドラム", - "monster_spawner": "バスドラム", - "concrete_powder": "スネアドラム", //コンクリートパウダー系 powderの優先度を上げる - "concrete": "バスドラム", //コンクリート系 - "gold_block": "ベル(グロッケンシュピール)", - "honeycomb_block": "フルート", - "monster_egg": "フルート", - "infested": "フルート", - "packed_ice": "チャイム", - "wool": "ギター", - "bone_block": "木琴", - "iron_block": "鉄琴", - "pumpkin": "ディジュリドゥ", - "emerald_block": "電子音", - "hay_block": "バンジョー", - "sand": "スネアドラム", //砂、赤砂、怪しげな砂 - "gravel": "スネアドラム", //砂利、怪しげな砂利 +const instrumentsTranslateKey = { + ja: { + "piano": "ピアノ", + "bass": "バス", + "bass_drum": "バスドラム", + "cow_bell": "カウベル", + "clicks_and_sticks": "スティック", + "flute": "フルート", + "pling_piano": "電子ピアノ", + "snare_drum": "スネアドラム", + "bells": "ベル", + "chimes": "チャイム", + "guitar": "ギター", + "xylophone": "木琴", + "iron_xylophone": "鉄琴", + "didgeridoo": "ディジュリドゥ", + "bit": "電子音", + "banjo": "バンジョー" }, - - english: { - "lit_pumpkin": "Piano", - "carved_pumpkin": "Piano", - "redstone_block": "Piano", - "_leaves": "Piano", - "note_block": "Bass", - "bookshelf": "Bass", - "oak": "Bass", - "spruce": "Bass", - "birch": "Bass", - "jungle": "Bass", - "acacia": "Bass", - "dark_oak": "Bass", - "cherry": "Bass", - "bamboo": "Bass", - "crimson": "Bass", - "warped": "Bass", - "mangrove": "Bass", - "chest": "Bass", - "crafting_table": "Bass", - "jukebox": "Bass", - "mushroom": "Bass", - "banner": "Bass", - "daylight_detector": "Bass", - "loom": "Bass", - "barrel": "Bass", - "cartography_table": "Bass", - "lectern": "Bass", - "smithing_table": "Bass", - "fletching_table": "Bass", - "campfire": "Bass", - "composter": "Bass", - "bee_nest": "Bass", - "beehive": "Bass", - "amethyst_block": "Bass Drum", - "soul_sand": "Cow Bell", - "glass": "Clicks and Sticks", - "sea_lantern": "Clicks and Sticks", - "beacon": "Clicks and Sticks", - "infested_": "Flute", - "glowstone": "Pling Piano", - "stone": "Bass Drum", - "andesite": "Bass Drum", - "granite": "Bass Drum", - "diorite": "Bass Drum", - "basalt": "Bass Drum", - "calcite": "Bass Drum", - "purpur": "Bass Drum", - "terracotta": "Bass Drum", - "quartz": "Bass Drum", - "tuff": "Bass Drum", - "blackstone": "Bass Drum", - "netherrack": "Bass Drum", - "nylium": "Bass Drum", - "obsidian": "Bass Drum", - "sandstone": "Bass Drum", - "_ore": "Bass Drum", - "deepslate": "Bass Drum", - "clay": "Bass Drum", - "raw_": "Bass Drum", - "brick": "Bass Drum", - "prismarine": "Bass Drum", - "coral": "Bass Drum", - "respawn_anchor": "Bass Drum", - "bedrock": "Bass Drum", - "observer": "Bass Drum", - "monster_spawner": "Bass Drum", - "concrete_powder": "Snare Drum", - "concrete": "Bass Drum", - "gold_block": "Bells", - "honeycomb_block": "Flute", - "monster_egg": "Flute", - "infested": "Flute", - "packed_ice": "Chimes", - "wool": "Guitar", - "bone_block": "Xylophone", - "iron_block": "Iron Xylophone", - "pumpkin": "Didgeridoo", - "emerald_block": "Bit", - "hay_block": "Banjo", - "sand": "Snare Drum", - "gravel": "Snare Drum" + en: { + "piano": "Piano", + "bass": "Bass", + "bass_drum": "Bass Drum", + "cow_bell": "Cow Bell", + "clicks_and_sticks": "Clicks and Sticks", + "flute": "Flute", + "pling_piano": "Pling Piano", + "snare_drum": "Snare", + "bells": "Bells", + "chimes": "Chimes", + "guitar": "Guitar", + "xylophone": "Xylophone", + "iron_xylophone": "Iron Xylophone", + "didgeridoo": "Didgeridoo", + "bit": "Bit", + "banjo": "Banjo" } } +const instruments = { + "lit_pumpkin": "piano", //上書き回避用 + "carved_pumpkin": "piano", //上書き回避用 + "redstone_block": "piano", //上書き回避用 + "_leaves": "piano", //葉系 + "noteblock": "bass", + "bookshelf": "bass", + "oak": "bass", //オークの木材系 + "spruce": "bass", //トウヒ系 + "birch": "bass", //樺系 + "jungle": "bass", //ジャングル系 + "acacia": "bass", //アカシア系 + "dark_oak": "bass", //ダークオーク系 + "cherry": "bass", //桜系 + "bamboo": "bass", //竹系 + "crimson": "bass", //クリムゾン系 + "warped": "bass", //歪んだ系 + "mangrove": "bass", //マングローブ系 + "chest": "bass", //チェスト系 + "crafting_table": "bass", + "jukebox": "bass", + "mushroom": "bass", //キノコ系 + "banner": "bass", //旗系 + "daylight_detector": "bass", + "loom": "bass", + "barrel": "bass", + "cartography_table": "bass", + "lectern": "bass", + "smithing_table": "bass", + "fletching_table": "bass", + "campfire": "bass", //焚き火系 + "composter": "bass", + "bee_nest": "bass", + "beehive": "bass", + "amethyst_block": "bass_drum", //アメジスト系 + "soul_sand": "cow_bell", + "glass": "clicks_and_sticks", //ガラス系 + "sea_lantern": "clicks_and_sticks", + "beacon": "clicks_and_sticks", + "infested_": "flute", //虫食いブロック系 + "glowstone": "pling_piano", + "stone": "bass_drum", //石系 + "andesite": "bass_drum", //安山岩系 + "granite": "bass_drum", //花崗岩系 + "diorite": "bass_drum", //閃緑岩系 + "basalt": "bass_drum", //玄武岩系 + "calcite": "bass_drum", + "purpur": "bass_drum", //プルプァ系 + "terracotta": "bass_drum", //色付き、彩釉テラコッタ系 + "quartz": "bass_drum", //クォーツブロック系 + "tuff": "bass_drum", //凝灰岩系 + "blackstone": "bass_drum", //ブラックストーン系 + "netherrack": "bass_drum", + "nylium": "bass_drum", //ナイリウム系 + "obsidian": "bass_drum", //黒曜石系 + "sandstone": "bass_drum", //砂岩系 + "_ore": "bass_drum", //鉱石系 + "deepslate": "bass_drum", //深層岩系 + "clay": "bass_drum", + "raw_": "bass_drum", //原石ブロック系 + "brick": "bass_drum", //レンガ系 + "prismarine": "bass_drum", //プリズマリン系 + "coral": "bass_drum", //サンゴ系 + "respawn_anchor": "bass_drum", + "bedrock": "bass_drum", + "observer": "bass_drum", + "monster_spawner": "bass_drum", + "concrete_powder": "snare_drum", //コンクリートパウダー系 上書き回避のため、コンクリートより優先度を上げる + "concrete": "bass_drum", //コンクリート系 + "gold_block": "bells", + "honeycomb_block": "flute", + "monster_egg": "flute", + "infested": "flute", + "packed_ice": "chimes", + "wool": "guitar", + "bone_block": "xylophone", + "iron_block": "iron_xylophone", + "pumpkin": "didgeridoo", + "emerald_block": "bit", + "hay_block": "banjo", + "sand": "snare_drum", //砂、赤砂、怪しげな砂 + "gravel": "snare_drum" //砂利、怪しげな砂利 +} + +world.beforeEvents.playerInteractWithBlock.subscribe(e => { + const { block, player, isFirstEvent, itemStack } = e; -world.beforeEvents.itemUseOn.subscribe(e => { - const { source, itemStack, block } = e; - const lang = source.getDynamicProperty("language"); + const lang = player.getDynamicProperty("language"); const ENGLISH = 0; const INTERNATIONAL = 1; - const scaleNotation = source.getDynamicProperty("scale_notation"); - const showClick = source.getDynamicProperty("show_click_count"); - const showInstrument = source.getDynamicProperty("show_instrument"); - const noteStick = "note:note_stick"; - const noteBlock = "minecraft:noteblock"; - if (!(itemStack.typeId == noteStick && block.typeId == noteBlock)) return; - if (source.isSneaking) { - e.cancel = true; + const scaleNotation = player.getDynamicProperty("scale_notation"); + const isDisplayClick = player.getDynamicProperty("is_display_click_count"); + const isDisplayInstrument = player.getDynamicProperty("is_display_instrument"); + if (!(block.typeId == "minecraft:noteblock" && isFirstEvent) || !player.getDynamicProperty("isEnable")) return; + if (player.isSneaking) { + if (itemStack !== undefined && BlockTypes.get(itemStack.typeId) !== undefined) { + return; + } else { + e.cancel = true; + } } - const permutation = block.dimension.getBlock({ x: block.location.x, y: block.dimension.heightRange.max - 1, z: block.location.z }).permutation; - block.dimension.runCommandAsync(`structure load __noteblocks ${block.location.x} ${block.dimension.heightRange.max - 1} ${block.location.z}`); + system.run(() => { + const permutation = block.dimension.getBlock({ x: block.location.x, y: block.dimension.heightRange.max - 1, z: block.location.z }).permutation; + block.dimension.runCommand(`structure load __noteblocks ${block.location.x} ${block.dimension.heightRange.max - 1} ${block.location.z}`); const chestInv = block.dimension.getBlock({ x: block.location.x, y: block.dimension.heightRange.max - 1, z: block.location.z }).getComponent("minecraft:inventory").container; chestInv.addItem(block.getItemStack(1, true)); //音ブロックをデータ付きでチェストに追加 for (let i = 0; i < chestInv.size; i++) { const slot = chestInv.getSlot(i); if (1 < slot.amount) { //アイテムが二個あるスロットを確認 const clickCount = i; - let resultMsg; - //音階を表示 + //音階 resultMsg = lang == ENGLISH ? "scale: " : "音階: "; - resultMsg += scaleNotation == INTERNATIONAL ? scales.international[clickCount] : scales.solfege[lang == ENGLISH ? "english" : "japanese"][clickCount]; - //クリック回数を表示 - resultMsg += showClick ? lang == ENGLISH ? " click: " + clickCount : " クリック: " + clickCount : ""; + if (scaleNotation == INTERNATIONAL) { + resultMsg += scales.international[clickCount]; + } else { + resultMsg += scales.solfege[lang == ENGLISH ? "en" : "ja"][clickCount]; + } + + //クリック数 + if (isDisplayClick) { + resultMsg += " click: " + clickCount; + } //楽器を表示 - if (showInstrument) { + if (isDisplayInstrument) { let instrument; - const underblock = source.dimension.getBlock({ x: block.location.x, y: block.location.y - 1, z: block.location.z }); - const keys = Object.keys(instruments?.[lang == ENGLISH ? "english" : "japanese"]) + const underblock = block.below(1); //1ブロック下のブロックを取得 + const keys = Object.keys(instruments) for (const key of keys) { if (underblock.typeId.includes(key)) { - instrument = instruments?.[lang == ENGLISH ? "english" : "japanese"][key]; + instrument = instrumentsTranslateKey[lang == ENGLISH ? "en" : "ja"][instruments[key]]; break; } } - if (!instrument) { //楽器が見つからなかったときの処理 + if (!instrument) { //楽器が見つからなかったときにピアノに instrument = lang == ENGLISH ? "piano" : "ピアノ" } resultMsg += lang == ENGLISH ? " instrument: " + instrument : " 楽器: " + instrument; } - source.onScreenDisplay.setActionBar(resultMsg); + player.onScreenDisplay.setActionBar(resultMsg); break; } } @@ -338,8 +301,8 @@ world.beforeEvents.itemUseOn.subscribe(e => { block.dimension.fillBlocks(volume, "minecraft:air"); block.dimension.getBlock({ x: block.location.x, y: block.dimension.heightRange.max - 1, z: block.location.z }).setPermutation(permutation); }) -}) +}) system.afterEvents.scriptEventReceive.subscribe(e => { const { id, sourceEntity } = e; @@ -349,8 +312,8 @@ system.afterEvents.scriptEventReceive.subscribe(e => { .title("設定") .dropdown("\n言語", ["English", "日本語"], sourceEntity.getDynamicProperty("language")) .dropdown("音階の表示形式", ["イタリア式(ドレミ)", "国際式(C,C#,D)"], sourceEntity.getDynamicProperty("scale_notation")) - .toggle("楽器を表示する", sourceEntity.getDynamicProperty("show_instrument")) - .toggle("クリック数を表示する", sourceEntity.getDynamicProperty("show_click_count")) + .toggle("楽器を表示する (Beta)", sourceEntity.getDynamicProperty("is_display_instrument")) + .toggle("クリック数を表示する", sourceEntity.getDynamicProperty("is_display_click_count")) .toggle("デフォルトに戻す") .submitButton("変更を適用") .show(sourceEntity).then(res => { @@ -361,8 +324,8 @@ system.afterEvents.scriptEventReceive.subscribe(e => { //設定の変更 sourceEntity.setDynamicProperty("language", res.formValues[0]); sourceEntity.setDynamicProperty("scale_notation", res.formValues[1]) - sourceEntity.setDynamicProperty("show_instrument", res.formValues[2]) - sourceEntity.setDynamicProperty("show_click_count", res.formValues[3]) + sourceEntity.setDynamicProperty("is_display_instrument", res.formValues[2]) + sourceEntity.setDynamicProperty("is_display_click_count", res.formValues[3]) } system.run(() => { @@ -379,8 +342,8 @@ system.afterEvents.scriptEventReceive.subscribe(e => { .title("Settings") .dropdown("\nLanguage", ["English", "日本語"], sourceEntity.getDynamicProperty("language")) .dropdown("scale notation", ["solfege(do,re,mi)", "international(C,C#,D)"], sourceEntity.getDynamicProperty("scale_notation")) - .toggle("Show instruments", sourceEntity.getDynamicProperty("show_instrument")) - .toggle("Show number of clicks", sourceEntity.getDynamicProperty("show_click_count")) + .toggle("Show instruments (Beta)", sourceEntity.getDynamicProperty("is_display_instrument")) + .toggle("Show number of clicks", sourceEntity.getDynamicProperty("is_display_click_count")) .toggle("Restore settings") .submitButton("Apply") .show(sourceEntity).then(res => { @@ -390,8 +353,8 @@ system.afterEvents.scriptEventReceive.subscribe(e => { } else { sourceEntity.setDynamicProperty("language", res.formValues[0]); sourceEntity.setDynamicProperty("scale_notation", res.formValues[1]) - sourceEntity.setDynamicProperty("show_instrument", res.formValues[2]) - sourceEntity.setDynamicProperty("show_click_count", res.formValues[3]) + sourceEntity.setDynamicProperty("is_display_instrument", res.formValues[2]) + sourceEntity.setDynamicProperty("is_display_click_count", res.formValues[3]) } system.run(() => { @@ -405,6 +368,14 @@ system.afterEvents.scriptEventReceive.subscribe(e => { }) } + } else if (id == "note:toggle") { + sourceEntity.setDynamicProperty("isEnable", !sourceEntity.getDynamicProperty("isEnable")); + system.run(() => { + sourceEntity.sendMessage(`${sourceEntity.getDynamicProperty("isEnable") ? "§e音階表示を有効にしました。" : "§e音階表示を無効にしました。"}`); + sourceEntity.playSound("random.orb"); + }) + } else if (id == "note:version") { + sourceEntity.sendMessage("§eNoteBlock+のバージョンは 1.1.4 です。") } }) @@ -414,6 +385,6 @@ system.afterEvents.scriptEventReceive.subscribe(e => { */ function initializeConfig(player) { player.setDynamicProperty("scale_notation", DefaultConfig.scale_notation); - player.setDynamicProperty("show_instrument", DefaultConfig.show_instrument); - player.setDynamicProperty("show_click_count", DefaultConfig.show_click_count); + player.setDynamicProperty("is_display_instrument", DefaultConfig.is_display_instrument); + player.setDynamicProperty("is_display_click_count", DefaultConfig.is_display_click_count); } \ No newline at end of file