Java 类net.minecraft.item.IItemPropertyGetter 实例源码

项目:Backmemed    文件:ItemOverride.java   
boolean matchesItemStack(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase livingEntity)
{
    Item item = stack.getItem();

    for (Entry<ResourceLocation, Float> entry : this.mapResourceValues.entrySet())
    {
        IItemPropertyGetter iitempropertygetter = item.getPropertyGetter((ResourceLocation)entry.getKey());

        if (iitempropertygetter == null || iitempropertygetter.apply(stack, worldIn, livingEntity) < ((Float)entry.getValue()).floatValue())
        {
            return false;
        }
    }

    return true;
}
项目:Mods    文件:ItemKnife.java   
public ItemKnife() {
    super();
    this.addPropertyOverride(new ResourceLocation("backstab"), new IItemPropertyGetter() {
        @Override
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
            if (entityIn == Minecraft.getMinecraft().player && Minecraft.getMinecraft().objectMouseOver != null
                    && Minecraft.getMinecraft().objectMouseOver.entityHit != null
                    && Minecraft.getMinecraft().objectMouseOver.entityHit
                            .getDistanceSqToEntity(entityIn) <= getMaxRange(stack) * getMaxRange(stack)
                    && isBackstab(entityIn, Minecraft.getMinecraft().objectMouseOver.entityHit))
                return 1;
            return 0;
        }
    });
}
项目:CustomWorldGen    文件:ItemOverride.java   
boolean matchesItemStack(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase livingEntity)
{
    Item item = stack.getItem();

    for (Entry<ResourceLocation, Float> entry : this.mapResourceValues.entrySet())
    {
        IItemPropertyGetter iitempropertygetter = item.getPropertyGetter((ResourceLocation)entry.getKey());

        if (iitempropertygetter == null || iitempropertygetter.apply(stack, worldIn, livingEntity) < ((Float)entry.getValue()).floatValue())
        {
            return false;
        }
    }

    return true;
}
项目:AdvancedCombat    文件:ItemBowAdvanced.java   
public ItemBowAdvanced() {
    super();
    this.setMaxDamage(1536);
    this.addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter() {
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack s, World world, EntityLivingBase e) {
            if (e == null) {
                return 0.0F;
            } else {
                ItemStack stack = e.getActiveItemStack();
                return stack != null && stack.getItem() == ItemBowAdvanced.this ? (float)(s.getMaxItemUseDuration() - e.getItemInUseCount()) / 10.0F : 0.0F;
            }
        }
    });
    this.setCreativeTab(ACCreativeTabs.main);
}
项目:Mekfarm    文件:AnimalPackageItem.java   
public AnimalPackageItem() {
    super("animal_package");

    this.addPropertyOverride(new ResourceLocation("hasAnimal"), new IItemPropertyGetter()
    {
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn)
        {
            NBTTagCompound nbt = ItemStackUtil.isEmpty(stack) ? null : stack.getTagCompound();
            if ((nbt != null) && (nbt.getInteger("hasAnimal") == 1)) {
                return 1;
            }
            return 0;
        }
    });
}
项目:RandomToolKit    文件:ItemHotSword.java   
public ItemHotSword(String name) {
    super(ToolMaterial.IRON);
    this.name = name;
    setUnlocalizedName(name);
    setRegistryName(name);
    setMaxDamage(3);

    RTK.proxy.registerItemRenderer(this, 0, name);

    addPropertyOverride(new ResourceLocation("heat"), new IItemPropertyGetter() {
        @Override
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity) {
            return stack.getMetadata();
        }
    });
}
项目:ExpandedRailsMod    文件:ItemOverride.java   
boolean matchesItemStack(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase livingEntity)
{
    Item item = stack.getItem();

    for (Entry<ResourceLocation, Float> entry : this.mapResourceValues.entrySet())
    {
        IItemPropertyGetter iitempropertygetter = item.getPropertyGetter((ResourceLocation)entry.getKey());

        if (iitempropertygetter == null || iitempropertygetter.apply(stack, worldIn, livingEntity) < ((Float)entry.getValue()).floatValue())
        {
            return false;
        }
    }

    return true;
}
项目:Soot    文件:ItemMug.java   
public ItemMug()
{
    super(CAPACITY);
    this.setHasSubtypes(true);
    this.setMaxStackSize(MAX_STACK_SIZE);
    this.addPropertyOverride(new ResourceLocation("fillmodel"),new IItemPropertyGetter(){
        @Override
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
            CaskLiquid liquid = getCaskLiquid(stack);
            if (liquid != null) return liquid.model;

            return 0;
        }
    });
}
项目:ToughExpansion    文件:ItemThirstQuencher.java   
public ItemThirstQuencher() {
    super(Options.THIRST_QUENCHER_RF_CAPACITY, Options.THIRST_QUENCHER_RF_CAPACITY, 40, NAME);
    setCreativeTab(ModCreativeTab.TAB);
    FLUID_CAPACITY = (Options.THIRST_QUENCHER_WATER_CAPACITY < 8 ? 8 : Options.THIRST_QUENCHER_WATER_CAPACITY) * 1000;
    addPropertyOverride(new ResourceLocation("filllevel"), new IItemPropertyGetter() {
        @Override
        public float apply(ItemStack stack, World world, EntityLivingBase entity) {
            return (getFluidStored(stack) / 1000) / 2;
        }
    });
}
项目:Defier    文件:PatternItem.java   
public PatternItem() {
    super("pattern");
    setMaxStackSize(1);
    this.addPropertyOverride(new ResourceLocation("defieritem"), new IItemPropertyGetter()
       {
           @SideOnly(Side.CLIENT)
           public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn)
           {
               if(!stack.hasTagCompound() || !stack.getTagCompound().hasKey("defieritem"))return 0f;
               return 1f;
           }
       });
}
项目:Mods    文件:ItemWeapon.java   
public ItemWeapon() {
    super();
    this.addPropertyOverride(new ResourceLocation("inhand"), new IItemPropertyGetter() {
        @Override
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
            if (entityIn != null && inHand)
                return 1;
            return 0;
        }
    });
}
项目:Mods    文件:ItemCloak.java   
public ItemCloak() {
    super();
    this.addPropertyOverride(new ResourceLocation("active"), new IItemPropertyGetter() {
        @Override
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
            if (entityIn != null && isFeignDeath(stack, entityIn) && WeaponsCapability.get(entityIn).isFeign())
                return 1;
            return 0;
        }
    });
}
项目:Mods    文件:ItemJar.java   
public ItemJar() {
    super();
    this.setMaxStackSize(64);
    this.addPropertyOverride(new ResourceLocation("empty"), new IItemPropertyGetter() {
        @Override
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
            if (stack.getTagCompound().getBoolean("IsEmpty"))
                return 1;
            return 0;
        }
    });
}
项目:Mods    文件:ItemMinigun.java   
public ItemMinigun() {
    super();
    this.addPropertyOverride(new ResourceLocation("spin"), new IItemPropertyGetter() {
        @Override
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
            if (entityIn != null && entityIn.hasCapability(TF2weapons.WEAPONS_CAP, null) && entityIn.getCapability(TF2weapons.WEAPONS_CAP, null).chargeTicks > 0)
                return 1;
            return 0;
        }
    });
}
项目:UHC-Compass    文件:ItemUHCCompass.java   
public ItemUHCCompass()
{
    this.addPropertyOverride(new ResourceLocation("angle"), new IItemPropertyGetter()
    {
        @SideOnly(Side.CLIENT)
        double rotation;
        @SideOnly(Side.CLIENT)
        double rota;
        @SideOnly(Side.CLIENT)
        long lastUpdateTick;
        @SideOnly(Side.CLIENT)
        @Override
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn)
        {
            Entity entity = Minecraft.getMinecraft().player;

            if (worldIn == null)
                worldIn = entity.world;

            double d0;

            double d1 = (double)entity.rotationYaw;
            d1 = d1 % 360.0D;
            double d2 = this.getSpawnToAngle(worldIn, entity);
            d0 = Math.PI - ((d1 - 90.0D) * 0.01745329238474369D - d2);

            float f = (float)(d0 / (Math.PI * 2D));
            return MathHelper.positiveModulo(f, 1.0F);
        }
        @SideOnly(Side.CLIENT)
        private double getSpawnToAngle(World p_185092_1_, Entity p_185092_2_)
        {
            BlockPos blockpos = new BlockPos(ConfigValues.TARGETX, 1, ConfigValues.TARGETZ);
            return Math.atan2((double)blockpos.getZ() - p_185092_2_.posZ, (double)blockpos.getX() - p_185092_2_.posX);
        }
    });
}
项目:BetterWithAddons    文件:ItemMonument.java   
public ItemMonument() {
    super();

    this.addPropertyOverride(new ResourceLocation("minecraft:blocking"), new IItemPropertyGetter(){

        @SideOnly(value= Side.CLIENT)
        @Override
        public float apply(ItemStack itemStack, @Nullable World world, @Nullable EntityLivingBase entityLivingBase) {
            return entityLivingBase != null && entityLivingBase.isHandActive() && entityLivingBase.getActiveItemStack() == itemStack ? 1.0f : 0.0f;
        }
    });
}
项目:Fyrestone    文件:ItemBaseSword.java   
public ItemBaseSword(ToolMaterial material, String regName)
{
    super(material);
    this.setRegistryName(regName);
    this.setUnlocalizedName(this.getRegistryName().toString());
    this.setCreativeTab(FyrestoneCreativeTabs.tabFyrestone);
    this.addPropertyOverride(new ResourceLocation("sword"), new IItemPropertyGetter()
    {
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn)
        {
            return ItemNBTHelper.getInt(stack, "sword_type", 0);
        }
    });
}
项目:HempFarmer    文件:HFResinShield.java   
public HFResinShield(String name) {
      this.maxStackSize = 1;
this.setRegistryName(name);
this.setUnlocalizedName(name);
addToItems(this);
      this.setMaxDamage(336);
      this.addPropertyOverride(new ResourceLocation("blocking"), new IItemPropertyGetter() {
          @SideOnly(Side.CLIENT)
          public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
              return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F;
          }
      });
  }
项目:geomastery    文件:ItemEdibleDecayable.java   
@SafeVarargs
public ItemEdibleDecayable(String name, int hunger, float saturation,
        int stackSize, EFoodType foodType, int shelfLife,
        Class<? extends EntityAnimal>... animalEaters) {

    super(name, hunger, saturation, stackSize, foodType, animalEaters);
    this.shelfLife = shelfLife;

    // Check whether the item is rotten for model
    this.addPropertyOverride(new ResourceLocation("rot"),
            new IItemPropertyGetter() {

        @Override
        public float apply(ItemStack stack, @Nullable World world,
                @Nullable EntityLivingBase entity) {

            if (world == null && entity != null) {

                world = entity.world;
            }

            if (stack.hasCapability(GeoCaps.CAP_DECAY, null)) {

                ICapDecay decayCap = stack
                        .getCapability(GeoCaps.CAP_DECAY, null);
                decayCap.updateFromNBT(stack.getTagCompound());

                if (decayCap.isRot(world)) {

                    return 1;
                }
            }

            return 0;
        }
    });
}
项目:geomastery    文件:ItemCarcassDecayable.java   
public ItemCarcassDecayable(BlockCarcass block, int stackSize) {

    super(block, stackSize);
    this.setCreativeTab(CreativeTabs.FOOD);
    this.shelfLife = block.getShelfLife();
    this.addPropertyOverride(new ResourceLocation("rot"),
            new IItemPropertyGetter() {

        @Override
        public float apply(ItemStack stack, @Nullable World world,
                @Nullable EntityLivingBase entity) {

            if (world == null && entity != null) {

                world = entity.world;
            }

            if (stack.hasCapability(GeoCaps.CAP_DECAY, null)) {

                ICapDecay decayCap = stack
                        .getCapability(GeoCaps.CAP_DECAY, null);
                decayCap.updateFromNBT(stack.getTagCompound());

                if (decayCap.isRot(world)) {

                    return 1;
                }
            }

            return 0;
        }
    });
}
项目:geomastery    文件:ItemSpear.java   
public ItemSpear(String name, ToolMaterial material,
        IProjectileFactory factory) {

    super(3F, -3.1F, material, Collections.emptySet());
    ItemSimple.setupItem(this, name, 1, CreativeTabs.COMBAT);
    this.factory = factory;

    // Check whether spear is being charged for the model
    this.addPropertyOverride(new ResourceLocation("pulling"),
            new IItemPropertyGetter() {

        @Override
        public float apply(ItemStack stack, @Nullable World world,
                @Nullable EntityLivingBase entity) {

            if (entity == null || !entity.isHandActive() ||
                    entity.getActiveItemStack() != stack) {

                return 0F;

            } else {

                return 1F;
            }
        }
    });
}
项目:RandomToolKit    文件:ItemDolly.java   
public ItemDolly(String name) {
    super(name);
    setCreativeTab(CreativeTabs.TOOLS);
    setMaxStackSize(1);
    addPropertyOverride(new ResourceLocation("full"), new IItemPropertyGetter() {
        @Override
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity) {
            boolean result = stack.getTagCompound() != null && stack.getTagCompound().hasKey("container");
            return result ? 1 : 0;
        }
    });
}
项目:RandomToolKit    文件:ItemToolbox.java   
public ItemToolbox(String name) {
    super(name);
    setCreativeTab(CreativeTabs.TOOLS);
    setMaxStackSize(1);
    addPropertyOverride(new ResourceLocation("open"), new IItemPropertyGetter() {
        @Override
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity) {
            boolean result = stack.getTagCompound() != null &&
                    stack.getTagCompound().hasKey("open") &&
                    stack.getTagCompound().getBoolean("open");
            return result ? 1 : 0;
        }
    });
}
项目:TaleCraft    文件:EntityCloneItem.java   
public EntityCloneItem() {
    this.addPropertyOverride(new ResourceLocation("full"), new IItemPropertyGetter(){
           @SideOnly(Side.CLIENT)
           public float apply(ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity){
               if (!stack.hasTagCompound()){
                   return 0.0F;
               }
               else{
                   NBTTagCompound tag = stack.getTagCompound();
                   return tag.hasKey("entity_data") ? 1.0F : 0.0F;
               }
           }
       });
}
项目:TaleCraft    文件:BoomerangItem.java   
public BoomerangItem() {
    super();
    this.addPropertyOverride(new ResourceLocation("thrown"), new IItemPropertyGetter(){
           @Override
                    @SideOnly(Side.CLIENT)
           public float apply(ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)    {
            return isThrown(stack) ? 1.0F : 0.0F;
           }
       });
}
项目:TaleCraft    文件:ThrowableKnifeItem.java   
public ThrowableKnifeItem() {
    super();
    this.addPropertyOverride(new ResourceLocation("thrown"), new IItemPropertyGetter(){
           @Override
                    @SideOnly(Side.CLIENT)
           public float apply(ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)    {
            return isThrown(stack) ? 1.0F : 0.0F;
           }
       });
}
项目:enderutilities    文件:ItemMobHarness.java   
@Override
protected void addItemOverrides()
{
    this.addPropertyOverride(new ResourceLocation(Reference.MOD_ID, "linked"), new IItemPropertyGetter()
    {
        @Override
        public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn)
        {
            return ItemMobHarness.this.hasTarget(stack) ? 1.0F : 0.0F;
        }
    });
}
项目:enderutilities    文件:ItemDolly.java   
@Override
protected void addItemOverrides()
{
    this.addPropertyOverride(new ResourceLocation(Reference.MOD_ID, "carrying"), new IItemPropertyGetter()
    {
        @Override
        public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn)
        {
            return ItemDolly.this.isCarryingBlock(stack) ? 1.0F : 0.0F;
        }
    });
}
项目:InspiringWorld    文件:ItemEnergyCompass.java   
public ItemEnergyCompass()
{
    this.addPropertyOverride(new ResourceLocation(InspiringMagic.MODID, "angle"), new IItemPropertyGetter()
    {
        @SideOnly(Side.CLIENT)
        double rotation;
        @SideOnly(Side.CLIENT)
        double rotaCache;
        @SideOnly(Side.CLIENT)
        long lastUpdateTick;

        @Override
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn)
        {
            if (entityIn == null)
                return 0;
            if (worldIn == null)
                worldIn = entityIn.worldObj;
            BlockPos entityPos = entityIn.getPosition();
            RuneRuin closest = RuneRuin.getClosest(worldIn, entityPos);
            if (closest == null)
                return 0;
            BlockPos position = closest.getPosition();

            return (float) BlockPoses.radiusOf(entityPos, position);
        }

        @SideOnly(Side.CLIENT)
        private double wobble(World world, double angle)
        {
            if (world.getTotalWorldTime() != this.lastUpdateTick)
            {
                this.lastUpdateTick = world.getTotalWorldTime();
                double mod = angle - this.rotation;
                mod = mod % (Math.PI * 2D);
                mod = MathHelper.clamp_double(mod, -1.0D, 1.0D);
                this.rotaCache += mod * 0.1D;
                this.rotaCache *= 0.8D;
                this.rotation += this.rotaCache;
            }

            return this.rotation;
        }
    });
}
项目:MCAnm    文件:ClientProxy.java   
@Override
public void preInit() {
    ModelLoaderRegistry.registerLoader(ModelLoader.INSTANCE);

    IResourceManager resManager = Minecraft.getMinecraft().getResourceManager();
    if (resManager instanceof IReloadableResourceManager) {
        IReloadableResourceManager registry = (IReloadableResourceManager) resManager;
        registry.registerReloadListener(new IResourceManagerReloadListener() {
            @Override
            public void onResourceManagerReload(IResourceManager p_110549_1_) {
                ClientProxy.reload();
            }
        });
    } else {
        MCAnm.logger()
                .warn("Couldn't register reload managers. Models will not be reloaded on switching resource pack");
    }

    if (MCAnm.isDebug) {
        ResourceLocation modelSrc = new ResourceLocation("mcanm:models/Cube/Cube.mcmd");
        @SuppressWarnings("deprecation")
        ISkeleton skeleton = CommonLoader.loadLegacySkeleton(modelSrc);
        IModel model = ClientLoader.loadModel(modelSrc, skeleton);
        IRenderFactory<CubeEntity> renderer = RenderAnimatedModel.fromModel(model, 1.0f);

        ResourceLocation model2Src = new ResourceLocation("mcanm:models/CubeV2/Cube.mcmd");
        IModel model2 = ClientLoader.loadModel(model2Src, ISkeleton.EMPTY);
        IRenderFactory<CubeEntityV2> renderer2 = RenderAnimatedModel
                .fromModel(makeAnimator("mcanm:textures/models/Cube/Untitled.png"), model2, 1.0f);

        RenderingRegistry.registerEntityRenderingHandler(CubeEntity.class, renderer);
        RenderingRegistry.registerEntityRenderingHandler(CubeEntityV2.class, renderer2);

        Item debug = new Item();
        debug.addPropertyOverride(new ResourceLocation("test"), new IItemPropertyGetter() {
            @Override
            public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn) {
                return (entityIn.ticksExisted / 100f) % 1f;
            }
        });
        GameRegistry.register(debug.setFull3D().setRegistryName("debug_item"));
        net.minecraftforge.client.model.ModelLoader.setCustomModelResourceLocation(
                debug,
                0,
                new ModelResourceLocation("mcanm:models/item/debug_item.mcmdl#inventory"));
    }
}