【釣りアイテム】

はじめに

ここでは本環境のビヘイビアパック内で定義しているオリジナルアイテムを例に挙げて、釣れるアイテムを定義するためのルートテーブル(Loot Table)の書き方をご紹介します。
基本的な書き方は関数設定も含めて▶基本の書き方の方でご紹介していますのでそちらをご覧ください。

※ルートテーブルの記述はJSON形式なのでJSONの仕様を理解している前提で話を進めます。

定義ファイルの所在

ビヘイビアパック内のloot_tables/gameplay/fishingというディレクトリ内で定義します。
例えばバニラのビヘイビアパックの場合は以下の構成になっています。
釣れるアイテムを定義しているファイル
/<ビヘイビアパックのルート>
    /loot_tables
        /gameplay
            /fishing
                fish.json           魚を抽選するルートテーブル(デフォルト)
                jungle_fish.json    魚を抽選するルートテーブル(ジャングルバイオーム)
                junk.json           ジャンク品を抽選するルートテーブル(デフォルト)
                jungle_junk.json    ジャンク品を抽選するルートテーブル(ジャングルバイオーム)
                treasure.json       宝物を抽選するルートテーブル
            fishing.json            抽選を実行するルートテーブルを決めるための定義(デフォルト)
            jungle_fishing.json     抽選を実行するルートテーブルを決めるための定義(ジャングルバイオーム)
                    

これに対して本環境の構成は以下の通り。
本環境のビヘイビアパック内のルートテーブルの構成
/for-family
    /loot_tables
        /gameplay
            /fishing
                fish.json           魚を抽選するルートテーブル(デフォルト)
                jungle_fish.json    魚を抽選するルートテーブル(ジャングルバイオーム)
                junk.json           ジャンク品を抽選するルートテーブル(デフォルト)
                jungle_junk.json    ジャンク品を抽選するルートテーブル(ジャングルバイオーム)
                treasure.json       宝物を抽選するルートテーブル
            fishing.json            抽選を実行するルートテーブルを決めるための定義(デフォルト)
                    

ご覧のように本環境ではjungle_fishing.jsonのみ除外しています。
除外している部分はバニラの定義が暗黙的に適用されます。

バニラの定義ファイルの内容


デフォルトの設定

gameplayディレクトリ直下のfishing.jsonファイル
{
    "pools": [
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "loot_table",
                    "name": "loot_tables/gameplay/fishing/junk.json",
                    "weight": 10,
                    "quality": -2
                },
                {
                    "type": "loot_table",
                    "name": "loot_tables/gameplay/fishing/treasure.json",
                    "weight": 5,
                    "quality": 2
                },
                {
                    "type": "loot_table",
                    "name": "loot_tables/gameplay/fishing/fish.json",
                    "weight": 85,
                    "quality": -1
                }
            ]
        }
    ]
}
                    

このファイルでは抽選の対象とするルートテーブルを決定するための内容が定義されています。
確率の高いものから順に取り上げると以下のようになります。
・fish.json(weight=85)
魚を抽選するルートテーブル。
・junk.json(weight=10)
ジャンク品を抽選するルートテーブル。
・treasure.json(weight=5)
宝物を抽選するルートテーブル。

ジャングルバイオームの設定

gameplayディレクトリ直下のjungle_fishing.jsonファイル
{
    "pools": [
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "loot_table",
                    "name": "loot_tables/gameplay/fishing/jungle_junk.json",
                    "weight": 10,
                    "quality": -2
                },
                {
                    "type": "loot_table",
                    "name": "loot_tables/gameplay/fishing/treasure.json",
                    "weight": 5,
                    "quality": 2
                },
                {
                    "type": "loot_table",
                    "name": "loot_tables/gameplay/fishing/jungle_fish.json",
                    "weight": 85,
                    "quality": -1
                }
            ]
        }
    ]
}
                    

このファイルではジャングルバイオーム限定で抽選の対象とするルートテーブルを決定するための内容が定義されています。
確率の高いものから順に取り上げると以下のようになります。
・jungle_fish.json(weight=85)
魚を抽選するルートテーブル。
・jungle_junk.json(weight=10)
ジャンク品を抽選するルートテーブル。
・treasure.json(weight=5)
宝物を抽選するルートテーブル。
上記の事からtreasure.jsonのルートテーブルはデフォルトの設定でもジャングルバイオームの設定でも同じものが使われている事がわかると思います。

※デフォルト/ジャングルバイオームの設定共にquality(プレイヤーの幸運属性)の項目が使用されています。これはJava版限定なので機能はしていませんがバニラデータには定義されています。

fish.jsonの定義

本環境では「生さんま」を追加で釣れるように設定しています。

※以下の黄色の部分が今回追加しているところです。
fish.jsonファイルの内容
{
    "pools": [
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "item",
                    "name": "minecraft:fish",
                    "weight": 30
                },
                {
                    "type": "item",
                    "name": "minecraft:salmon",
                    "weight": 25
                },
                {
                    "type": "item",
                    "name": "minecraft:clownfish",
                    "weight": 2
                },
                {
                    "type": "item",
                    "name": "minecraft:pufferfish",
                    "weight": 13
                },

                {
                    "type": "item",
                    "name": "customize:sanma",
                    "weight": 30
                }

            ]
        }
    ]
}
                    

このファイルではweightの配分の合計が元々百分率で計算できるように100で設定されているようなのでminecraft:fishの60の値を半分ずつ分け合ってcustomize:sanmaと同率になるようにしています。

jungle_fish.jsonの定義

本環境ではジャングルバイオームでも「生さんま」を追加で釣れるように設定しています。

※以下の黄色の部分が今回追加しているところです。
jungle_fish.jsonファイルの内容
{
    "pools": [
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "item",
                    "name": "minecraft:fish",
                    "weight": 30
                },
                {
                    "type": "item",
                    "name": "minecraft:salmon",
                    "weight": 40
                },

                {
                    "type": "item",
                    "name": "customize:sanma",
                    "weight": 30
                }

            ]
        }
    ]
}
                    

このファイルではweightの配分の合計が元々百分率で計算できるように100で設定されているようなのでminecraft:fishの60の値を半分ずつ分け合ってcustomize:sanmaと同率になるようにしています。

junk.jsonの定義

本環境ではジャンク品として「G合金」「PS装甲」を追加で釣れるように設定しています。

※以下の黄色の部分が今回追加しているところです。
junk.jsonファイルの内容
{
    "pools": [
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "item",
                    "name": "minecraft:leather_boots",
                    "weight": 10,
                    "functions": [
                        {
                            "function": "set_damage",
                            "damage": {
                                "min": 0,
                                "max": 0.90
                            }
                        }
                    ]
                },
                {
                    "type": "item",
                    "name": "minecraft:leather",
                    "weight": 10
                },
                {
                    "type": "item",
                    "name": "minecraft:bone",
                    "weight": 10
                },
                {
                    "type": "item",
                    "name": "minecraft:potion",
                    "weight": 10
                },
                {
                    "type": "item",
                    "name": "minecraft:string",
                    "weight": 5
                },
                {
                    "type": "item",
                    "name": "minecraft:fishing_rod",
                    "weight": 2,
                    "functions": [
                        {
                            "function": "set_damage",
                            "damage": {
                                "min": 0,
                                "max": 0.90
                            }
                        }
                    ]
                },
                {
                    "type": "item",
                    "name": "minecraft:bowl",
                    "weight": 10
                },
                {
                    "type": "item",
                    "name": "minecraft:stick",
                    "weight": 5
                },
                {
                    "type": "item",
                    "name": "minecraft:dye",
                    "weight": 1,
                    "functions": [
                        {
                            "function": "set_data",
                            "data": 0
                        },
                        {
                            "function": "set_count",
                            "count": 10
                        }
                    ]
                },
                {
                    "type": "item",
                    "name": "minecraft:tripwire_hook",
                    "weight": 10
                },
                {
                    "type": "item",
                    "name": "minecraft:rotten_flesh",
                    "weight": 10
                },

                {
                    "type": "item",
                    "name": "customize:g_alloy",
                    "weight": 10
                },
                {
                    "type": "item",
                    "name": "customize:ps_armor",
                    "weight": 5
                }

            ]
        }
    ]
}
                    


jungle_junk.jsonの定義

本環境ではジャングルバイオームでもジャンク品として「G合金」「PS装甲」を追加で釣れるように設定しています。

※以下の黄色の部分が今回追加しているところです。
jungle_fish.jsonファイルの内容
{
    "pools": [
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "item",
                    "name": "minecraft:leather_boots",
                    "weight": 10,
                    "functions": [
                        {
                            "function": "set_damage",
                            "damage": {
                                "min": 0,
                                "max": 0.90
                            }
                        }
                    ]
                },
                {
                    "type": "item",
                    "name": "minecraft:leather",
                    "weight": 10
                },
                {
                    "type": "item",
                    "name": "minecraft:bone",
                    "weight": 10
                },
                {
                    "type": "item",
                    "name": "minecraft:potion",
                    "weight": 10
                },
                {
                    "type": "item",
                    "name": "minecraft:string",
                    "weight": 5
                },
                {
                    "type": "item",
                    "name": "minecraft:fishing_rod",
                    "weight": 2,
                    "functions": [
                        {
                            "function": "set_damage",
                            "damage": {
                                "min": 0,
                                "max": 0.90
                            }
                        }
                    ]
                },
                {
                    "type": "item",
                    "name": "minecraft:bowl",
                    "weight": 10
                },
                {
                    "type": "item",
                    "name": "minecraft:stick",
                    "weight": 5
                },
                {
                    "type": "item",
                    "name": "minecraft:dye",
                    "weight": 1,
                    "functions": [
                        {
                            "function": "set_data",
                            "data": 0
                        },
                        {
                            "function": "set_count",
                            "count": 10
                        }
                    ]
                },
                {
                    "type": "item",
                    "name": "minecraft:dye",
                    "weight": 10,
                    "functions": [
                        {
                            "function": "set_data",
                            "data":3
                        },
                        {
                            "function": "set_count",
                            "count": 1
                        }
                    ]
                },
                {
                    "type": "item",
                    "name": "minecraft:tripwire_hook",
                    "weight": 10
                },
                {
                    "type": "item",
                    "name": "minecraft:rotten_flesh",
                    "weight": 10
                },
                {
                    "type": "item",
                    "name": "minecraft:bamboo",
                    "weight": 10
                },

                {
                    "type": "item",
                    "name": "customize:g_alloy",
                    "weight": 10
                },
                {
                    "type": "item",
                    "name": "customize:ps_armor",
                    "weight": 5
                }

            ]
        }
    ]
}
                    


treasure.jsonの定義

本環境では「不動の杖」の材料となる「不動の魔石(customize:immovable_stone)」と「浮遊の羽(customize:floating_feather)」の素材を釣りで取得できるように設定しています。
分類としては宝物になるため、今回はtreasure.jsonファイルに以下のように定義しています。

※以下の黄色の部分が今回追加しているところです。
treasure.jsonファイルの内容
{
    "pools": [
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "item",
                    "name": "minecraft:nautilus_shell",
                    "weight": 5
                },
                {
                    "type": "item",
                    "name": "minecraft:waterlily",
                    "weight": 5
                },
                {
                    "type": "item",
                    "name": "minecraft:name_tag",
                    "weight": 5
                },
                {
                    "type": "item",
                    "name": "minecraft:saddle",
                    "weight": 5
                },
                {
                    "type": "item",
                    "name": "minecraft:bow",
                    "weight": 5,
                    "functions": [
                        {
                            "function": "set_damage",
                            "damage": {
                                "min": 0,
                                "max": 0.25
                            }
                        },
                        {
                            "function": "enchant_with_levels",
                            "levels": 30,
                            "treasure": true
                        }
                    ]
                },
                {
                    "type": "item",
                    "name": "minecraft:fishing_rod",
                    "weight": 5,
                    "functions": [
                        {
                            "function": "set_damage",
                            "damage": {
                                "min": 0,
                                "max": 0.25
                            }
                        },
                        {
                            "function": "enchant_with_levels",
                            "levels": 30,
                            "treasure": true
                        }
                    ]
                },
                {
                    "type": "item",
                    "name": "minecraft:book",
                    "weight": 6,
                    "functions": [
                        {
                            "function": "enchant_with_levels",
                            "levels": 30,
                            "treasure": true
                        }
                    ]
                },

                {
                    "type": "item",
                    "name": "customize:immovable_stone",
                    "weight": 5,
                    "functions": [
                        {
                            "function": "set_name",
                            "name": "不動の魔石"
                        },
                        {
                            "function": "set_lore",
                            "lore": [
                                "動くものを足止めする力を秘めている"
                            ]
                        }
                    ]
                },
                {
                    "type": "item",
                    "name": "customize:floating_feather",
                    "weight": 6,
                    "functions": [
                        {
                            "function": "set_name",
                            "name": "浮遊の羽"
                        },
                        {
                            "function": "set_lore",
                            "lore": [
                                "浮力を付与する効果がある"
                            ]
                        }
                    ]
                }

            ]
        }
    ]
}
                    


おわりに

登録した釣りアイテムを確認する際は「入れ食い」のエンチャントを付与した釣り竿を使った方が時間短縮になります。
また、そのままでは確率まかせになってしまうのであまり効率的とは言えません。今回の場合、宝物アイテムを登録しているのでgameplay直下のfishing.jsonを一時的に修正するのがいいでしょう。

例えば魚のルートテーブルとジャンク品のルートテーブルのweight値をゼロにしておけば100%の確率で宝物を引き当てる事ができます。
本環境のビヘイビアパックにはバニラデータのまま入れていますが、この時のためにすぐに対応できるよう敢えて同梱しています。

あとはtreasure.jsonの中にもお目当てのアイテム以外の定義が入っていますので、他のアイテムのweight値をゼロにするか、お目当てのアイテムだけ異様に高い数値にすれば対応できるでしょう。


今回使用したカスタムアイテムの内容は以下のページでご紹介しています。
・生さんま(customize:sanma)
食料アイテムの作り方として▶食料アイテムのページでご紹介しています。

・G合金(customize:g_alloy)
▶ファンネルユニットのレシピ材料としてご紹介しています。

・PS装甲(customize:ps_armor)
▶ホバーユニットのレシピ材料としてご紹介しています。

・不動の魔石(customize:immobable_stone)、浮遊の羽(customize:floating_feather)
▶不動の杖構成アイテムのページで使い方をご紹介しています。

※カスタムアイテムの場合、アイテム名の前に必ずネームスペース(今回の場合は”customize”)を付けるようにしましょう。