Java 类net.minecraft.entity.passive.HorseArmorType 实例源码

项目:Gravestone-mod-Extended    文件:EntityUndeadHorse.java   
@Override
public void readEntityFromNBT(NBTTagCompound compound) {
    super.readEntityFromNBT(compound);

    if (compound.hasKey("ArmorItem", 10)) {
        ItemStack itemstack = new ItemStack(compound.getCompoundTag("ArmorItem"));

        if (!itemstack.isEmpty() && HorseArmorType.isHorseArmor(itemstack.getItem())) {
            this.horseChest.setInventorySlotContents(1, itemstack);
        }
    }

    this.updateHorseSlots();
}
项目:Gravestone-mod-Extended    文件:EntityUndeadHorse.java   
@Override
public void onInventoryChanged(IInventory invBasic) {
    HorseArmorType horsearmortype = this.getHorseArmorType();
    super.onInventoryChanged(invBasic);
    HorseArmorType horsearmortype1 = this.getHorseArmorType();

    if (this.ticksExisted > 20 && horsearmortype != horsearmortype1 && horsearmortype1 != HorseArmorType.NONE) {
        this.playSound(SoundEvents.ENTITY_HORSE_ARMOR, 0.5F, 1.0F);
    }
}
项目:Gravestone-mod-Extended    文件:EntityUndeadHorse.java   
public void setHorseArmorStack(ItemStack itemStackIn) {
    HorseArmorType horsearmortype = HorseArmorType.getByItemStack(itemStackIn);
    this.dataManager.set(HORSE_ARMOR, horsearmortype.getOrdinal());
    this.resetTexturePrefix();

    if (!this.world.isRemote) {
        this.getEntityAttribute(SharedMonsterAttributes.ARMOR).removeModifier(ARMOR_MODIFIER_UUID);
        int i = horsearmortype.getProtection();

        if (i != 0) {
            this.getEntityAttribute(SharedMonsterAttributes.ARMOR).applyModifier((new AttributeModifier(ARMOR_MODIFIER_UUID, "Horse armor bonus", (double) i, 0)).setSaved(false));
        }
    }
}
项目:Gravestone-mod-Extended    文件:EntityUndeadHorse.java   
@SideOnly(Side.CLIENT)
private void setHorseTexturePaths() {
    HorseArmorType horsearmortype = this.getHorseArmorType();
    this.horseTexturesArray[0] = getUndeadHorseTexture();
    this.horseTexturesArray[1] = horsearmortype.getTextureName();
    this.texturePrefix = ModInfo.ID + ":undead_horse/" + getUndeadHorseTexture() + horsearmortype.getHash();
}
项目:OpenModLoader    文件:GameRegistry.java   
/**
 * Initializes the registry.
 */
public static void init() {
    Registries.register(HorseArmorType.class);
    registerHorseArmor(new ResourceLocation("none"), HorseArmorType.NONE);
    registerHorseArmor(new ResourceLocation("iron"), HorseArmorType.IRON);
    registerHorseArmor(new ResourceLocation("gold"), HorseArmorType.GOLD);
    registerHorseArmor(new ResourceLocation("diamond"), HorseArmorType.DIAMOND);
    Registries.register(WorldGenerator.class);
}
项目:OpenModLoader    文件:GameRegistry.java   
/**
 * Registers a horse armor.
 *
 * @param id the ID of the horse armor. Must be unique.
 * @param type the horse armor type
 */
public static void registerHorseArmor(ResourceLocation id, HorseArmorType type) {
    AutomaticNamespacedRegistry<ResourceLocation, HorseArmorType> registry = Registries.get(HorseArmorType.class);
    if (type == null) {
        throw new NullPointerException("Attempted to register a null horse armor");
    } else if (id == null) {
        throw new NullPointerException("Attempted to register a horse armor with a null ID");
    } else if (registry.containsKey(id)) {
        throw new IllegalArgumentException(String.format("The horse armor ID \"%s\" has already been registered", id));
    }
    registry.register(id, type);
}
项目:MMDLib-old    文件:ASMHooks.java   
@SideOnly(Side.CLIENT)
public static String getTextureName (HorseArmorType type, EntityHorse entity) {
    final ItemStack stack = entity.getDataManager().get(ASMHooks.ARMOR_STACK).orNull();
    if (stack != null && stack.getItem() instanceof IHorseArmor)
        return ((IHorseArmor) stack.getItem()).getArmorTexture(entity, stack);
    return type.getTextureName();
}
项目:Gravestone-mod-Extended    文件:EntityUndeadHorse.java   
@Override
protected void entityInit() {
    super.entityInit();
    this.dataManager.register(HORSE_ARMOR, HorseArmorType.NONE.getOrdinal());
}
项目:Gravestone-mod-Extended    文件:EntityUndeadHorse.java   
public HorseArmorType getHorseArmorType() {
    return HorseArmorType.getByOrdinal(this.dataManager.get(HORSE_ARMOR));
}
项目:Gravestone-mod-Extended    文件:EntityUndeadHorse.java   
@Override
public boolean processInteract(EntityPlayer player, EnumHand hand) {
    ItemStack itemstack = player.getHeldItem(hand);
    boolean stackNotEmpty = !itemstack.isEmpty();

    if (stackNotEmpty && itemstack.getItem() == Items.SPAWN_EGG) {
        return super.processInteract(player, hand);
    } else if (!this.isTame() && !this.isChild() && player.isSneaking()) {
        this.openGUI(player);
        return true;
    } else if (this.isBeingRidden()) {
        return super.processInteract(player, hand);
    } else if (stackNotEmpty) {
        boolean flag = false;
        float healedHealth = 0;
        short growth = 0;
        if (itemstack.getItem() == Items.BONE) {
            healedHealth = 2;
            growth = 20;
        } else if (itemstack.getItem() == Items.ROTTEN_FLESH) {
            healedHealth = 4;
            growth = 60;
        }

        if (this.getHealth() < this.getMaxHealth() && healedHealth > 0) {
            this.heal(healedHealth);
            flag = true;
        }

        if (this.isChild() && growth > 0) {
            this.addGrowth(growth);
            flag = true;
        }


        if (flag) {
            if (!player.capabilities.isCreativeMode) {
                itemstack.shrink(1);
            }

            return true;
        } else {
            if (!this.isTame()) {
                if (itemstack.interactWithEntity(player, this, hand)) {
                    return true;
                }

                this.setRearing(true);
                return true;
            }
        }

        if (HorseArmorType.getByItemStack(itemstack) != HorseArmorType.NONE || !this.isHorseSaddled() && itemstack.getItem() == Items.SADDLE) {
            this.openGUI(player);
            return true;
        }

        if (itemstack.interactWithEntity(player, this, hand)) {
            return true;
        }
    }

    this.mountTo(player);
    return true;
}
项目:Gravestone-mod-Extended    文件:EntityUndeadHorse.java   
@Override
public boolean isArmor(ItemStack stack) {
    return HorseArmorType.isHorseArmor(stack.getItem());
}
项目:OpenModLoader    文件:TestHorseArmor.java   
@Override
public HorseArmorType getArmorType(ItemStack stack) {
    return TYPE;
}
项目:MMDLib-old    文件:ItemTestArmor.java   
@Override
public HorseArmorType getArmorType () {
    return HorseArmorType.DIAMOND;
}
项目:MMDLib-old    文件:HorseArmorUtils.java   
@Nullable
public HorseArmorType createHorseArmorType (int strength, @Nonnull String name, @Nonnull String hash) {
    return EnumHelper.addEnum(HorseArmorType.class, name.toUpperCase().replace(" ", "_"), new Class[] { int.class, String.class, String.class }, strength, name, hash);
}
项目:OpenModLoader    文件:HorseArmor.java   
/**
 * Gets the HorseArmorType to use for this horse armor.
 * 
 * @param stack The ItemStack instance of the armor.
 * @return The HorseArmorType to use for the armor item.
 */
HorseArmorType getArmorType(ItemStack stack);
项目:MMDLib-old    文件:IHorseArmor.java   
/**
 * Returns the {@link HorseArmorType} of the custom horse armor.
 *
 * @return The {@link HorseArmorType} that this horse armor will have the values of.
 */
HorseArmorType getArmorType ();