HackMD
    • Create new note
    • Create a note from template
    • Sharing Link copied
    • /edit
    • View mode
      • Edit mode
      • View mode
      • Book mode
      • Slide mode
      Edit mode View mode Book mode Slide mode
    • Customize slides
    • Note Permission
    • Read
      • Only me
      • Signed-in users
      • Everyone
      Only me Signed-in users Everyone
    • Write
      • Only me
      • Signed-in users
      • Everyone
      Only me Signed-in users Everyone
    • Commenting & Invitee
    • Publishing
      Please check the box to agree to the Community Guidelines.
      Everyone on the web can find and read all notes of this public team.
      After the note is published, everyone on the web can find and read this note.
      See all published notes on profile page.
    • Commenting Enable
      Disabled Forbidden Owners Signed-in users Everyone
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Invitee
    • No invitee
    • Options
    • Versions and GitHub Sync
    • Transfer ownership
    • Delete this note
    • Note settings
    • Template
    • Save as template
    • Insert from template
    • Export
    • Dropbox
    • Google Drive Export to Google Drive
    • Gist
    • Import
    • Dropbox
    • Google Drive Import from Google Drive
    • Gist
    • Clipboard
    • Download
    • Markdown
    • HTML
    • Raw HTML
Menu Note settings Sharing Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Transfer ownership Delete this note
Export
Dropbox Google Drive Export to Google Drive Gist
Import
Dropbox Google Drive Import from Google Drive Gist Clipboard
Download
Markdown HTML Raw HTML
Back
Sharing
Sharing Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Comment & Invitee
Publishing
Please check the box to agree to the Community Guidelines.
Everyone on the web can find and read all notes of this public team.
After the note is published, everyone on the web can find and read this note.
See all published notes on profile page.
More (Comment, Invitee)
Commenting Enable
Disabled Forbidden Owners Signed-in users Everyone
Permission
Owners
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Invitee
No invitee
   owned this note    owned this note      
Published Linked with GitHub
Like BookmarkBookmarked
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# 脱出マップで使うMinecraftコマンドの話 こちらは **法政大学Advent Calender 2021** 15日目の記事となります。 ## はじめに 今Minecraft(JAVA版)にて脱出系マップを鋭意作成中なので、その中で使ったコマンドの中で汎用性が高そうなものを載せようと思います。 ## 使うもの、コマンド ### コマンドブロック Minecfaftのコマンドは基本的にはゲーム内のプレイヤーが実行します。コマンドブロックはプレイヤーの代わりにコマンドを実行してくれるアイテムであり、それを利用した様々なギミックを展開できます。コマンドブロックには以下の3種類が存在し、今回もそれらを使い分けます。 ![](https://i.imgur.com/YsRPCqf.png) 左は普通の、真ん中は前のコマンドブロックに続いて実行される、右は常時実行(デーモン的な)です。 ### executeコマンド 今回主に使用するコマンドです。execute言葉としての意味は「計画、仕事などを実行する」といった意味を持ちます。 コマンドの形式は`execute 条件 run 実行する内容` といった感じで、条件が満たされていた場合、コマンドを実行します。「条件」と「実行する内容」の部分を変えることでさまざまなギミックが実装できます。 ## 応用例1 - 1回だけタイトルを出す {%youtube P2PoBro-OH4 %} 紫のコマンドブロックを1個目とするとコマンドは以下のようになります。 1個目 `execute unless block 座標A stone run title @p times 20 100 20` 2個目 `execute unless block 座標A stone run title @p subtitle {"text":"subtitle"}` 3個目 `execute unless block 座標A stone run title @p title {"text":"title"}` 4個目 `fill 始点座標(座標A) 終点座標(座標A) minecraft:stone` 1個目の`unless block`はそのブロックが特定の場所にない限り`run`以降のコマンド(今回は`title`)を実行します。特定の場所というのは3次元座標で指定しており、今回は座標A(コマンドブロックの真上)となっています。 2, 3, 4個目は1個目のコマンドが実行された場合のみ連鎖的に実行されます。2, 3個目は実際にタイトルを出すコマンドです。 4個目は座標Aにフラグとなるブロック(今回はstone)を置くコマンドを実行し、1個目のコマンドブロックがもう一度実行されないようにしています。 特定の場所を通ったときに、1回だけフィールド名を出したりするのに使っています。 ## 応用例2 - 特定の持ち物を持っているときに1回だけイベントを発生させる {%youtube NJ62-fs97B0 %} 先ほどのフラグの例の発展系です。焼肉を持っている状態で話しかけると門を開けてくれます。このやり取りは1回だけ行われます。流れは以下のような感じです。 ![](https://i.imgur.com/1hxzZSz.png) 画像奥のコマンドブロックのコマンドは `execute unless block 座標B blackstone run say ゾンビ「お腹すいた」` となっており、座標Bにblackstoneがない(フラグが立っていない)なら、`say ゾンビ「お腹すいた」`を実行します。`say`は指定した文字列を表示するコマンドです。 ![](https://i.imgur.com/3YNbNua.png) プレイヤー生肉を持っている場合は以下を実行します。これが実行されてもフラグは立ちません。 `execute if entity @p[nbt={Inventory:[{id:”minecraft:porkchop”}]}] run say ゾンビ「生肉じゃやだ」` `if entity @p[nbt={Inventory:[{id:”minecraft:porkchop”}]}]`は生肉を持っているプレイヤーがいるなら、`run`以降のコマンドを実行するといった意味合いになります。 ![](https://i.imgur.com/Ousk4R8.png) 焼肉をもっている場合、画像手前のブロックから順番に実行されます。 1個目 `execute at @a[nbt={Inventory:[{id:”minecraft:cooked_porkchop”}]}] run say ゾンビ「ありがとう!」` 2個目 `clear @p cooked_porkchop` 3個目 `fill 始点座標(座標B) 終点座標(座標B) blackstone` 4個目 `fill 始点座標(座標C) 終点座標(座標D) air` 2個目の`clear`はプレイヤーの持ち物から焼肉を消します。 また3個目のコマンドでは座標Bにフラグを立てています。 4個目のコマンドは、焼肉をもらった見返りとして門を開けるコマンドです。 ![](https://i.imgur.com/Hz2Nljd.png) このコマンドは `execute if block 座標B blackstone run say ゾンビ「門を開けたよ」` となっており、フラグが立っている状態(座標Bに`blackstone`がある)でのみ実行されます。 ![](https://i.imgur.com/am58X1e.png) フラグが立った状態です。 ## 応用例3 - 絵合わせ {%youtube RSiKGGKk5sQ %} 左右のタイルの組み合わせが一致しているときにイベントが発生します。パズルギミックなどに利用できます。 ![](https://i.imgur.com/gQDDNdB.png) 複雑そうな動作ですが、ブロック1つで事足ります。 `execute if blocks 座標E 座標F 座標G all run say atteru!` `if blocks`は座標Eから座標Fまでのブロックの並びと、座標Gから同じだけ進んだところまでのブロックの並びが一致していれば`run`以降のコマンドを実行します。 ## 応用例4 - ワープ {%youtube IzqBBhr-DRs %} くぐるだけでワープ可能なゲートです。スイッチやレバーがいらないので見栄えがいいです。 ![](https://i.imgur.com/58aIHgl.png) コマンドブロックをゲートの下に埋め込んでいます。 `execute positioned 座標H if entity @p[distance..1] run tp @p 座標I` `positioned`は条件の基準となる場所を指定します。今回はプレイヤーが座標Hから半径1ブロック以内にいる場合(`if entity @p[distance..1]`)のみ`run`以降のコマンドを実行します。`tp`は指定した座標にプレイヤーを移動させるコマンドとなっています。 ## まとめ 脱出マップを作成する上でコマンドブロックとexecuteコマンドは必須なので、皆様も脱出マップを作る機会があるときは(あるのか?)ぜひ活用しましょう。 ## 参考 [executeコマンドについて](https://minecraft.fandom.com/ja/wiki/コマンド/execute)

Import from clipboard

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lost their connection.

Create a note from template

Create a note from template

Oops...
This template is not available.


Upgrade

All
  • All
  • Team
No template found.

Create custom template


Upgrade

Delete template

Do you really want to delete this template?

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Tutorials

Book Mode Tutorial

Slide Mode Tutorial

YAML Metadata

Contacts

Facebook

Twitter

Discord

Feedback

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions

Versions and GitHub Sync

Sign in to link this note to GitHub Learn more
This note is not linked with GitHub Learn more
 
Add badge Pull Push GitHub Link Settings
Upgrade now

Version named by    

More Less
  • Edit
  • Delete

Note content is identical to the latest version.
Compare with
    Choose a version
    No search result
    Version not found

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub

      Please sign in to GitHub and install the HackMD app on your GitHub repo. Learn more

       Sign in to GitHub

      HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Available push count

      Upgrade

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Upgrade

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully