提供: Minecraft Modding Wiki
この編集を取り消せます。
下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 | 編集中の文章 | ||
3行目: | 3行目: | ||
{{チュートリアルカテゴリー|difficulty=0|type=Block}} | {{チュートリアルカテゴリー|difficulty=0|type=Block}} | ||
ワールド上で鉱石のようにブロックを生成する方法 | ワールド上で鉱石のようにブロックを生成する方法 | ||
+ | |||
+ | 動作確認済みのバージョン:1.16.3 | ||
==鉱石を生成する== | ==鉱石を生成する== | ||
11行目: | 13行目: | ||
import net.fabricmc.api.ModInitializer; | import net.fabricmc.api.ModInitializer; | ||
− | import net.minecraft.block. | + | import net.minecraft.item.Item; |
+ | import net.minecraft.block.Block; | ||
+ | import net.minecraft.item.BlockItem; | ||
+ | import net.minecraft.item.ItemGroup; | ||
import net.minecraft.util.Identifier; | import net.minecraft.util.Identifier; | ||
− | |||
import net.minecraft.util.registry.Registry; | import net.minecraft.util.registry.Registry; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
public class SampleMod implements ModInitializer | public class SampleMod implements ModInitializer | ||
32行目: | 31行目: | ||
.configure(new OreFeatureConfig( | .configure(new OreFeatureConfig( | ||
OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, | OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, | ||
− | Blocks.OAK_LOG.getDefaultState(), | + | Blocks.OAK_LOG.getDefaultState(), |
9)) //鉱石(生成物)の最大サイズ | 9)) //鉱石(生成物)の最大サイズ | ||
.decorate(Decorator.RANGE.configure(new RangeDecoratorConfig( | .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig( | ||
39行目: | 38行目: | ||
64))) //鉱石(生成物)Y座標の最大レベル | 64))) //鉱石(生成物)Y座標の最大レベル | ||
.spreadHorizontally() | .spreadHorizontally() | ||
− | .repeat(20); //1チャンクあたりの鉱石(生成物)の数 | + | .repeat(20); // 1チャンクあたりの鉱石(生成物)の数 |
@Override | @Override | ||
48行目: | 47行目: | ||
} | } | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
</source> | </source> | ||
78行目: | 54行目: | ||
"required": true, | "required": true, | ||
"minVersion": "0.8", | "minVersion": "0.8", | ||
− | "package": "com. | + | "package": "com.github.ptom76.trialmod.mixin", |
"compatibilityLevel": "JAVA_8", | "compatibilityLevel": "JAVA_8", | ||
− | |||
"mixins": [ | "mixins": [ | ||
− | " | + | "DefaultBiomeFeaturesMixin" |
], | ], | ||
"client": [ | "client": [ | ||
− | " | + | "MixinMain" |
], | ], | ||
"injectors": { | "injectors": { | ||
93行目: | 68行目: | ||
</source> | </source> | ||
==解説== | ==解説== | ||
− | |||
− | |||
<source lang = "java"> | <source lang = "java"> | ||
− | + | public static final Block SAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL).build()); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</source> | </source> | ||
− | + | 素材を金属として設定。 | |
− | + | ブロックを作成。 | |
− | + | <source lang = "java"> | |
− | + | Registry.register(Registry.BLOCK, new Identifier(MOD_ID, "sample_block"), SAMPLE_BLOCK); | |
− | + | Registry.register(Registry.ITEM, new Identifier(MOD_ID, "sample_block"), new BlockItem(SAMPLE_BLOCK, new Item.Settings().group(ItemGroup.MISC))); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</source> | </source> | ||
− | + | ブロックIDとアイテムIDの登録。 | |
− | + | ブロックをアイテムとしてクリエイティブタグ、ItemGroup.MISC(その他)に登録。 |