Search in sources :

Example 1 with IItemPropertyGetter

use of net.minecraft.item.IItemPropertyGetter in project Skree by Skelril.

the class LoadedBow method applyPropertyOverrides.

private void applyPropertyOverrides() {
    this.addPropertyOverride(new ResourceLocation("skree", "pull"), new IItemPropertyGetter() {

        @SideOnly(Side.CLIENT)
        public float apply(ItemStack item, @Nullable World world, @Nullable EntityLivingBase living) {
            if (living == null) {
                return 0.0F;
            } else {
                ItemStack itemstack = living.getActiveItemStack();
                return itemstack != null ? (item.getMaxItemUseDuration() - living.getItemInUseCount()) / 20.0F : 0.0F;
            }
        }
    });
    this.addPropertyOverride(new ResourceLocation("skree", "pulling"), new IItemPropertyGetter() {

        @SideOnly(Side.CLIENT)
        public float apply(ItemStack item, @Nullable World world, @Nullable EntityLivingBase living) {
            return living != null && living.isHandActive() && living.getActiveItemStack() == item ? 1.0F : 0.0F;
        }
    });
}
Also used : IItemPropertyGetter(net.minecraft.item.IItemPropertyGetter) ResourceLocation(net.minecraft.util.ResourceLocation) EntityLivingBase(net.minecraft.entity.EntityLivingBase) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World)

Aggregations

EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 IItemPropertyGetter (net.minecraft.item.IItemPropertyGetter)1 ItemStack (net.minecraft.item.ItemStack)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 World (net.minecraft.world.World)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1