LoginSignup
1
2

More than 5 years have passed since last update.

Forgeの鉱石辞書を利用したレシピ追加

Posted at

概要

レシピの素材指定に鉱石辞書を使う方法の説明をします。

鉱石辞書自体はこちらの記事で解説しています。

コード

バニラのレシピと同じように、鉱石辞書利用レシピにも定形レシピと不定形レシピがあります。

それぞれ、ShapedOreRecipeクラスとShapelessOreRecipeクラスを利用します。

基本的にはItemやBlockのインスタンスを指定していた箇所を、鉱石辞書に登録した文字列に変更するだけです。

定形レシピ

CraftManagerにShapedOreRecipeのインスタンスを登録します。


CraftingManager.getInstance().addRecipe(new ShapedOreRecipe(new ItemStack(Blocks.PLANKS, 1),
                new Object[] {
                        "xxx", "xxx", "xxx",
                        'x', "stickWood"
                }));

このコードでは木の棒を3*3に並べると木材になるレシピを追加しています。

木の棒の指定が"stickWood"で、鉱石辞書に登録した文字列になっているので、
バニラ+Modで追加された全ての木の棒を素材にすることが出来ます。

不定形レシピ

CraftManagerにShapelessOreRecipeのインスタンスを登録します。


CraftingManager.getInstance().addRecipe(new ShapelessOreRecipe(new ItemStack(Items.DIAMOND, 1),
                new Object[] {
                        "paper"
                }));

このコードでは紙をダイアモンドにクラフトするレシピを追加しています。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2