環境
- Mac OS X Yosemite
- Java 1.8.0_25
- Eclipse Mars.1 Release (4.5.1)
ソース
package in.webya.Chrowa3Sample;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraftforge.common.util.EnumHelper;
public class Chrowa3Item extends ItemSword
{
public static ToolMaterial CHROWA3 = EnumHelper.addToolMaterial("CHROWA3", 3, 3000, 20.0F, 20.0F, 30);
public Chrowa3Item(){
super(CHROWA3);
setCreativeTab(CreativeTabs.tabMaterials);
setUnlocalizedName("Chrowa3Item");
setFull3D();
setMaxStackSize(1);
}
@Override
public String getItemStackDisplayName(ItemStack itemstack)
{
return "Excalibur";
}
}
武器のパラメーター、例えば攻撃力などをカスタムしたい場合は、ToolMaterial という構造体に上記の様なフォーマットで追加し、コンストラクタ内の super() に渡します。
Item クラス に定義されている構造体のコンストラクタは以下のとおり
private ToolMaterial(int harvestLevel, int maxUses, float efficiency, float damageVsEntity, int enchantability)
{
this.harvestLevel = harvestLevel;
this.maxUses = maxUses;
this.efficiencyOnProperMaterial = efficiency;
this.damageVsEntity = damageVsEntity;
this.enchantability = enchantability;
}