提供: Minecraft Modding Wiki
1.6のモデル付きカスタムツール追加
このアイテムは、(つるはし)(ショベル)(斧)の三つ(鉄製)にモデルを付けて追加するものです。
ソース
- CustomModelTools.java
package custom.tool.item; import net.minecraft.item.EnumToolMaterial; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; @Mod( modid = "CustomModelTools", name = "Custom Model Tools", version = "1" ) @NetworkMod( clientSideRequired = CustomModelTools.clientSideRequiredBoolean, serverSideRequired = CustomModelTools.serverSideRequiredBoolean ) public class CustomModelTools { public static final boolean clientSideRequiredBoolean = true; public static final boolean serverSudeRequiredBoolean = false; public static EnumToolMaterial toolMaterial; public static ItemTool mainItem; @EventHabdler public void mainLoading(FMLPreInitializationEvent event) { mainItem = new ItemCustomModelTools(3001, toolMaterial.rock); } public void registerItem(Item items, name) { GameReigstry.registerItem(items, name); LanguageRegistry.addNameForObject(items, name); } }
- ItemCustomModelTools.java
package custom.tool.item; import net.minecraft.item.ItemTool; import net.minecraft.item.EnumToolMaterial; import net.minecraft.block.Block; public class ItemCustomModelTools extends ItemTool { private static final Block[] setBleakingList = new Block[] {// ItemSpade.java Block.grass, Block.dirt, Block.sand, Block.gravel, Block.snow, Block.blockSnow, Block.blockClay, Block.tilledField, Block.slowSand, Block.mycelium // ItemPickaxe.java Block.cobblestone, Block.stoneDoubleSlab, Block.stoneSingleSlab, Block.stone, Block.sandStone, Block.cobblestoneMossy, Block.oreIron, Block.blockIron, Block.oreCoal, Block.blockGold, Block.oreGold, Block.oreDiamond, Block.blockDiamond, Block.ice, Block.netherrack, Block.oreLapis, Block.blockLapis, Block.oreRedstone, Block.oreRedstoneGlowing, Block.rail, Block.railDetector, Block.railPowered, Block.railActivator // ItemAxe.java Block.planks, Block.bookShelf, Block.wood, Block.chest, Block.stoneDoubleSlab, Block.stoneSingleSlab, Block.pumpkin, Block.pumpkinLantern}; // 詳しい情報は、ItemSpade.java ItemPickaxe.java ItemAxe.javaを参照 public ItemCustomModelTools(int par1ID, EnumToolMaterial par2EnumToolMaterial) { super(par1ID, damageFloat, par2EnumToolMaterial, setBleakingList); } @Override public boolean canHarvestBlock(Block par1Block) { return par1Block == Block.snow ? true : par1Block == Block.blockSnow : //雪 (par1Block == Block.obsidian ? this.toolMaterial.getHarvestLevel() == 3 : //黒曜石 (par1Block != Block.blockDiamond && par1Block != Block.oreDiamond ? //ダイヤモンド (par1Block != Block.oreEmerald && par1Block != Block.blockEmerald ? //エメラルド (par1Block != Block.blockGold && par1Block != Block.oreGold ? //金 (par1Block != Block.blockIron && par1Block != Block.oreIron ? //鉄 (par1Block != Block.blockLapis && par1Block != Block.oreLapis ? //ラピスラズリ (par1Block != Block.oreRedstone && par1Block != Block.oreRedstoneGlowing ? //レッドストーン (par1Block.blockMaterial == Material.rock ? true : //マテリアル属性 石 (par1Block.blockMaterial == Material.iron ? true : //マテリアル属性 鉄 par1Block.blockMaterial == Material.anvil)) //マテリアル属性 金床 this.toolMaterial.getHarvestLevel() >= 2) : //マテリアルレベル 2 this.toolMaterial.getHarvestLevel() >= 1) : //マテリアルレベル 1 this.toolMaterial.getHarvestLevel() >= 1) : //マテリアルレベル 1 this.toolMaterial.getHarvestLevel() >= 2) : //マテリアルレベル 2 this.toolMaterial.getHarvestLevel() >= 2) : //マテリアルレベル 2 this.toolMaterial.getHarvestLevel() >= 2)); //マテリアルレベル 2 } @Override public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block) { return par2Block != null && (par2Block.blockMaterial == Material.iron || //マテリアル属性 鉄 par2Block.blockMaterial == Material.anvil || //マテリアル属性 金床 par2Block.blockMaterial == Material.rock || //マテリアル属性 石 par2Block.blockMaterial == Material.wood || //マテリアル属性 原木 par2Block.blockMaterial == Material.plants || //マテリアル属性 木の厚板 par2Block.blockMaterial == Material.vine) ? //マテリアル属性 つる this.efficiencyOnProperMaterial : super.getStrVsBlock(par1ItemStack, par2Block); } public Item setData(String domain, String path) { setUnlocalizedName(path); iconString = domain + ":" + path; } }
未完成