ko_kr:tutorial:blocks
                Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| ko_kr:tutorial:blocks [2021/04/07 04:54] – created themovieayt | ko_kr:tutorial:blocks [2023/08/14 16:13] (current) – namutree0345 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== 블록 추가하기 ====== | ====== 블록 추가하기 ====== | ||
| - | 블록을 추가하는 방법은 아이템을 추가하는 것과 비슷합니다. | + | 블록을 추가하는 방법은  | 
| + | |||
| + | ===== 블록 인스턴스 만들기 ===== | ||
| + | '' | ||
| + | |||
| + | <code java [enable_line_numbers=" | ||
| + | public class ExampleMod implements ModInitializer { | ||
| + | |||
| + | /* 우리의 커스텀 블록 인스턴스를 선언하고 초기화합니다. | ||
| + |         | ||
| + | |||
| + |         | ||
| + | |||
| + |         | ||
| + |         | ||
| + | |||
| + |         | ||
| + | */ | ||
| + |     public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL).strength(4.0f)); | ||
| + | |||
| + | @Override | ||
| + | public void onInitialize() { | ||
| + | |||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== 블록 등록하기 ==== | ||
| + | |||
| + | 블록은 '' | ||
| + | |||
| + | <code java [enable_line_numbers=" | ||
| + | public class ExampleMod implements ModInitializer { | ||
| + | |||
| + |     public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL).strength(4.0f)); | ||
| + | |||
| + | @Override | ||
| + | public void onInitialize() { | ||
| + |         Registry.register(Registry.BLOCK, | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | 당신의 커스텀 블록은 아이템으로 아직 접근할 수 없을 것입니다. 하지만 게임 내에서는 ''/ | ||
| + | |||
| + | ==== 블록 아이템 등록하기 ==== | ||
| + | |||
| + | 대부분의 경우에는 당신은 아이템을 통해 당신의 블록을 설치하게 하고 싶을 것 입니다. 이 것을 위해 당신은 Registry.ITEM 저장소에 그 블록에 맞는 BlockItem을 등록해야합니다. 저장소에 등록된 블록 아이템의 이름은 주로 블록의 저장소 이름과 같습니다. | ||
| + | |||
| + | <code java [enable_line_numbers=" | ||
| + | public class ExampleMod implements ModInitializer { | ||
| + | |||
| + |     public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL).strength(4.0f)); | ||
| + | |||
| + | @Override | ||
| + | public void onInitialize() { | ||
| + |         Registry.register(Registry.BLOCK, | ||
| + |         Registry.register(Registry.ITEM, | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== 블록에게 시각적 요소 부여하기 ===== | ||
| + | |||
| + | 현재까지는 당신의 블록은 게임 내에서 보라색과 검은색의 체크 무늬로 표시될 것입니다. 마인크래프트는 블록의 에셋을 로딩하는 중 문제가 발생했을 때 이렇게 표시합니다. 이 문제의 전체 내용은 클라이언트를 실행할 때 출력되는 로그에서 확인할 수 있습니다. | ||
| + | 당신은 블록에게 시각적 요소를 부여하기 위해 다음의 파일이 필요합니다 | ||
| + | * 블록 상태 파일 | ||
| + | * 블록 모델 파일 | ||
| + | * 텍스쳐 | ||
| + | * 만약 블록 아이템이 있을 경우, 아이템 모델 파일 | ||
| + | |||
| + | 해당 파일들은 다음 위치에 위치되어야 합니다: | ||
| + | |||
| + |   블록 상태: src/ | ||
| + |   블록 모델: src/ | ||
| + |   아이템 모델: src/ | ||
| + |   텍스쳐: src/ | ||
| + | |||
| + | 블록 상태 파일은 블록의 블록 상태(blockstate)에 따라 어떤 블록 모델을 사용할지 결정합니다. 우리의 블록은 상태라고 할 게 딱히 없으니 우리는 블록 상태 파일을 다음과 같이 작성할 수 있을 것입니다. | ||
| + | ''""'' | ||
| + | |||
| + | <code JavaScript src/ | ||
| + | { | ||
| + |   " | ||
| + |     "": | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | 블록 모델 파일은 당신의 블록의 모양과 텍스쳐를 결정합니다. 우리의 모델은 모든 면에 같은 텍스쳐를 적용하는 '' | ||
| + | |||
| + | <code JavaScript src/ | ||
| + | { | ||
| + |   " | ||
| + |   " | ||
| + |     " | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | 대부분의 경우에는 블록 아이템을 블록과 똑같이 보이길 원할 것입니다. 그렇다면 당신은 블록 모델을 부모로 삼는 아이템 모델을 다음과 같이 작성하면 됩니다. | ||
| + | |||
| + | <code JavaScript src/ | ||
| + | { | ||
| + |   " | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | 이제 마인크래프트를 켜고 블록의 시각적인 요소를 확인해보세요! | ||
| + | |||
| + | ===== 블록 드랍 설정하기 ===== | ||
| + | |||
| + | 블록이 부숴졌을 때 아이템이 떨어지게 하고 싶으면, //루트 테이블// | ||
| + | |||
| + | <code JavaScript src/ | ||
| + | { | ||
| + |   " | ||
| + |   " | ||
| + | { | ||
| + |       " | ||
| + |       " | ||
| + | { | ||
| + |           " | ||
| + |           " | ||
| + | } | ||
| + | ], | ||
| + |       " | ||
| + | { | ||
| + |           " | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== 커스텀 블록 클래스 만들기 ===== | ||
| + | |||
| + | The above approach works well for simple items but falls short when you want a block with //unique// mechanics. We'll create a // | ||
| + | |||
| + | <code java [enable_line_numbers=" | ||
| + | public class ExampleBlock extends Block { | ||
| + | |||
| + | public ExampleBlock(Settings settings) { | ||
| + |         super(settings); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | You can override methods in the block class for custom functionality. Here's an implementation of the '' | ||
| + | |||
| + | <code java [enable_line_numbers=" | ||
| + | public class ExampleBlock extends Block { | ||
| + | |||
| + | public ExampleBlock(Settings settings) { | ||
| + |         super(settings); | ||
| + | } | ||
| + | |||
| + | @Override | ||
| + | public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { | ||
| + | if (!world.isClient) { | ||
| + |             player.sendMessage(new LiteralText(" | ||
| + | } | ||
| + | |||
| + |         return ActionResult.SUCCESS; | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | To use your custom block class, replace //new Block// with //new ExampleBlock//: | ||
| + | |||
| + | <code java [enable_line_numbers=" | ||
| + | public class ExampleMod implements ModInitializer { | ||
| + | |||
| + |     public static final ExampleBlock EXAMPLE_BLOCK = new ExampleBlock(Block.Settings.of(Material.STONE).hardness(4.0f)); | ||
| + | |||
| + | @Override | ||
| + | public void onInitialize() { | ||
| + |         Registry.register(Registry.BLOCK, | ||
| + |         Registry.register(Registry.ITEM, | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== Custom VoxelShape ==== | ||
| + | |||
| + | When using block models that do not // | ||
| + | |||
| + | {{: | ||
| + | |||
| + | To fix this, we have to define the '' | ||
| + | |||
| + | < | ||
| + |   | ||
| + |   | ||
| + |       | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Note that the //collision shape// of the block defaults to the outline shape if it is not specified. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | ===== Next Steps ===== | ||
| + | [[tutorial: | ||
| + | |||
| + | [[tutorial: | ||
ko_kr/tutorial/blocks.1617771247.txt.gz · Last modified: 2021/04/07 04:54 by themovieayt