먼저 bellcraft.items 패키지에 ItemIngots 클래스를 추가해줍니다.
그리고 다음과 같이 코딩해줍니다.
ItemIngots.java
package bellcraft.items;
import java.util.List;
import bellcraft.core.BellCraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.oredict.OreDictionary;
public class ItemIngots extends Item {
private final String customUnlocalizedName;
private final String customName;
public ItemIngots(String arg1, String arg2)
{
super();
setCreativeTab(BellCraft.tab); // 방울크래프트 탭에 아이템 추가
customUnlocalizedName = arg1; // 아이템명 받아옴
customName = arg2; // 아이템 정보 받아옴
OreDictionary.registerOre("ingot" + customUnlocalizedName, this); // 오어 딕셔너리 등록
}
@Override
public String getUnlocalizedName()
{
return BellCraft.MODID + ".ingot" + customUnlocalizedName;
}
@Override
public String getUnlocalizedName(ItemStack item)
{
return BellCraft.MODID + ".ingot" + customUnlocalizedName;
}
@Override
public void registerIcons(IIconRegister register)
{
this.itemIcon = register.registerIcon(BellCraft.MODID + ":ingot" + customUnlocalizedName);
}
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4)
{
list.add(EnumChatFormatting.BLUE + customName); // 아이템 정보 등록, 앞은 글씨 색
}
}
다음에는 bellcraft.items 패키지에 Items 클래스에 들어가줍니다.
Items.java
public static Item ingotCopper;
public static Item ingotCobalt;
ingotCopper = new ItemIngots("Copper", "BC Copper");
ingotCobalt = new ItemIngots("Cobalt", "BC Cobalt");
GameRegistry.registerItem(ingotCopper, "ingotCopper");
GameRegistry.registerItem(ingotCobalt, "ingotCobalt");
위 선언은 Items 클래스에 선언해주시고,
아래 명령줄은 registerItems 메소드에 추가해줍니다.
언어설정은 BellCraft.ingotCopper.name=구리
형식으로 하시면됩니다.
텍스쳐는 리소스폴더의 아이템 패키지에 ingotCopper.png 형식으로 추가하시면 됩니다.
'Game Dev > MineCraft - Mod' 카테고리의 다른 글
| 광물블럭 추가 및 월드에서 광물 자동생성하기 (0) | 2014.12.01 |
|---|---|
| 랜덤박스 티어별로 생성 및 랜덤아이템교환기능 추가하기 (0) | 2014.12.01 |
| 서버 명령어 추가하기 (0) | 2014.11.30 |
| 모드 패키지 정렬하기 (0) | 2014.11.30 |
| 한 슬롯에 아이템을 최대 몇개 가질 수 있는지 지정하기 (0) | 2014.11.30 |
댓글