개인 자료란 (JE)

  서버 커뮤니티

Profile NamuTree0345 대표칭호 없음
Profile

질문하기 Java

Block을 Registry 할때 오류납니다.

2020.03.28 조회 수 327 추천 수 0
이해도 모드 
게임버전 (JE) 포지 

오류가 납니다. 버전은

마인크래프트: 1.12.2

포지: 14.23.5.2847

입니다.


블럭을 Registry 할때 오류가 납니다.

Model 에 모델도 만들어 두고...

textures에 텍스쳐도 넣어놓고

blockstates에도 만들어뒀는데!

아래의 RegistryHandler에서 오류가 나네요...


다음 코드는 RegistryHandler 코드입니다.

ackage NamuTree0345.tutorialmod.util.handlers;

import NamuTree0345.tutorialmod.init.ModBlocks; import NamuTree0345.tutorialmod.init.ModItems; import NamuTree0345.tutorialmod.util.IHasModel; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@EventBusSubscriber public class RegistryHandler {

@SubscribeEvent
public static void onItemRegister(RegistryEvent.Register event) {
    event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
}

@SubscribeEvent
public static void onBlockRegister(RegistryEvent.Register event) {
    event.getRegistry().registerAll(ModBlocks.BLOCKS.toArray(new Block[0]));
}

@SubscribeEvent
public static void onModelRegister(ModelRegistryEvent event) {
    for (Item item:ModItems.ITEMS) {

        if (item instanceof IHasModel) {
            ((IHasModel)item).registerModels();
        }

    }

    for (Block block:ModBlocks.BLOCKS) {

        if (block instanceof IHasModel) {
            ((IHasModel)block).registerModels();
        }

    }
}

}

다음 코드는 ModBlocks 코드 입니다.

ackage NamuTree0345.tutorialmod.init;

import java.util.ArrayList;

import NamuTree0345.tutorialmod.blocks.BlockOreLv1; import net.minecraft.block.Block; import net.minecraft.block.material.Material;

public class ModBlocks {

public static final ArrayList BLOCKS = new ArrayList();

// 광석
public static final Block COPPER_ORE = new BlockOreLv1("copper_ore", Material.IRON, 5.0F);
public static final Block TIN_ORE = new BlockOreLv1("tin_ore", Material.IRON, 5.0F);

}

다음 코드는 BlockBase 코드입니다.

ackage NamuTree0345.tutorialmod.blocks;

import NamuTree0345.tutorialmod.init.ModBlocks; import NamuTree0345.tutorialmod.init.ModItems; import NamuTree0345.tutorialmod.main.TutorialMod; import NamuTree0345.tutorialmod.util.IHasModel; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemBlock;

public class BlockBase extends Block implements IHasModel{

public BlockBase(String name, Material material) {

    super(material);
    setUnlocalizedName(name);
    setRegistryName(name);
    setHardness(5.0F);
    setCreativeTab(CreativeTabs.BUILDING_BLOCKS);

    ModBlocks.BLOCKS.add(this);
    ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(name));

}

@Override
public void registerModels() {
    TutorialMod.proxy.registerItemRenderer(new ItemBlock(this), 0, "inventory");
}

}

다음 코드는 BlockOreLv1 코드입니다.

ackage NamuTree0345.tutorialmod.blocks;

import NamuTree0345.tutorialmod.init.ModBlocks; import NamuTree0345.tutorialmod.init.ModItems; import NamuTree0345.tutorialmod.main.TutorialMod; import NamuTree0345.tutorialmod.util.IHasModel; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemBlock;

public class BlockBase extends Block implements IHasModel{

public BlockBase(String name, Material material) {

    super(material);
    setUnlocalizedName(name);
    setRegistryName(name);
    setHardness(5.0F);
    setCreativeTab(CreativeTabs.BUILDING_BLOCKS);

    ModBlocks.BLOCKS.add(this);
    ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(name));

}

@Override
public void registerModels() {
    TutorialMod.proxy.registerItemRenderer(new ItemBlock(this), 0, "inventory");
}

}

오류난 내용:

errorNea.txt

참고로 gradlew runclient로 실행했습니다.

1개의 댓글

NamuTree0345
2020.03.29

아 고쳤습니다! BlockBase에서 TutorialMod.proxy.registerItemRenderer(new ItemBlock(this), 0, "inventory"); 가 아니라 TutorialMod.proxy.registerItemRenderer(Item.getItemFromBlock(this),0,"inventory"); 하니까 오류가 없어졌네요!