现在,我们有了一把无敌的剑,但仅靠这些显然是不够的,我们还需要一套无敌的盔甲,具体要实现:无视伤害,全套时可以飞行
直接上代码
ItemDirtArmor.java:
package fenge.fmltutor.item;
import fenge.fmltutor.ExampleMod;
import fenge.fmltutor.creativetab.TabFMLTutor;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
//继承ItemArmor
public class ItemDirtArmor extends ItemArmor
{
public ItemDirtArmor(EntityEquipmentSlot equipmentSlot)
{
//设置盔甲属性
super(ItemRegistryHandler.DIRT_ARMOR_MATERIAL, 0, equipmentSlot);
this.setUnlocalizedName(ExampleMod.MODID + ".dirtArmor." + equipmentSlot.getName());
//设置UnlocalizedName
this.setRegistryName("dirt_armor_" + equipmentSlot.getName());
//设置RegistryName
this.setCreativeTab(TabFMLTutor.TAB_FMLTUTOR);
//设置所在物品栏
}
//没用的属性
public Boolean ZT = false;
//当盔甲被穿上时调用
@SideOnly(Side.CLIENT)
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack){
if (player.inventory.armorItemInSlot(2).getItem()==ItemRegistryHandler.DIRT_CHESTPLATE &&
player.inventory.armorItemInSlot(2)!=null ||
player.inventory.armorItemInSlot(3).getItem()==ItemRegistryHandler.DIRT_HELMET &&
player.inventory.armorItemInSlot(3)!=null ||
player.inventory.armorItemInSlot(0).getItem()==ItemRegistryHandler.DIRT_BOOTS &&
player.inventory.armorItemInSlot(0)!=null ||
player.inventory.armorItemInSlot(1).getItem()==ItemRegistryHandler.DIRT_LEGGINGS &&
player.inventory.armorItemInSlot(1)!=null) {
//只要穿上其中的一件,就赋予急迫III,生命恢复三,并将血量设为满血
effectPlayer(player, MobEffects.HASTE,10,3);
effectPlayer(player, MobEffects.REGENERATION,10,3);
//TODO effectPlayer(player, PotionRegistryHa

本文介绍了一个名为无敌盔甲的MOD实现过程,该MOD能让玩家角色无视伤害,并且当全套盔甲装备齐全时还能获得飞行能力。文章详细展示了ItemDirtArmor.java代码,包括盔甲属性设置、穿戴效果及飞行能力的实现。
最低0.47元/天 解锁文章
2398

被折叠的 条评论
为什么被折叠?



