LoginSignup
4
4

More than 5 years have passed since last update.

Minecraft 1.8.9 Forge API を使った Mod開発「武器追加 サンプルソース」

Posted at

環境

  • 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;
}

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4