net.minecraft.item.IItemPropertyGetter Java Examples

The following examples show how to use net.minecraft.item.IItemPropertyGetter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IPearlBelt.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
default void addBeltColorProperty(Item item) {
	item.addPropertyOverride(new ResourceLocation("slot"), new IItemPropertyGetter() {
		@SideOnly(Side.CLIENT)
		public float apply(@Nonnull ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
			IItemHandler handler = getPearls(stack);
			if (handler == null) return 0;

			int total = 0;
			for (int i = 0; i < handler.getSlots(); i++) {
				ItemStack pearl = handler.getStackInSlot(i);
				if (pearl.isEmpty()) continue;

				total++;
			}

			return MathHelper.clamp(total, 0, 6);
		}
	});
}
 
Example #2
Source File: ItemTofuCore.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public ItemTofuCore() {
    super();
    this.setMaxStackSize(1);
    this.setMaxDamage(300);
    this.setUnlocalizedName(TofuMain.MODID + "." + "tofucore");
    this.addPropertyOverride(new ResourceLocation("broken"), new IItemPropertyGetter() {
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
            return isUsable(stack) ? 0.0F : 1.0F;
        }
    });
}
 
Example #3
Source File: ItemTofuForceSword.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public ItemTofuForceSword() {
    super(TofuToolMaterial.FORCE, "tofuforce_sword");
    this.addPropertyOverride(new ResourceLocation("broken"), new IItemPropertyGetter() {
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
            return isUsable(stack) ? 0.0F : 1.0F;
        }
    });
}
 
Example #4
Source File: ItemTofuForceCore.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public ItemTofuForceCore() {
    super();
    this.setMaxStackSize(1);
    this.setMaxDamage(360);
    this.setUnlocalizedName(TofuMain.MODID + "." + "tofuforce_core");
    this.addPropertyOverride(new ResourceLocation("broken"), new IItemPropertyGetter() {
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
            return isUsable(stack) ? 0.0F : 1.0F;
        }
    });
}
 
Example #5
Source File: ItemFukumame.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public ItemFukumame() {
    this.maxStackSize = 1;
    this.setMaxDamage(64);
    this.setUnlocalizedName(TofuMain.MODID + "." + "fukumame");
    BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, new DispenserBehaviorFukumame());
    this.addPropertyOverride(new ResourceLocation("empty"), new IItemPropertyGetter() {

        @Override
        public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn) {
            return stack.getItemDamage() > stack.getMaxDamage() ? 1.0f : 0.0f;
        }

    });
}
 
Example #6
Source File: ItemKotachi.java    From Sakura_mod with MIT License 5 votes vote down vote up
public ItemKotachi(Item.ToolMaterial material, String name) {
    this.material = material;
    this.maxStackSize = 1;
    this.setMaxDamage((int) (material.getMaxUses()*0.75f));
    this.setUnlocalizedName(SakuraMain.MODID + "." + name);
    this.attackDamage = material.getAttackDamage();
    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;
        }
    });
}
 
Example #7
Source File: ItemKatana.java    From Sakura_mod with MIT License 5 votes vote down vote up
public ItemKatana(Item.ToolMaterial material, String name) {
    this.material = material;
    this.maxStackSize = 1;
    this.setMaxDamage(material.getMaxUses());
    this.setUnlocalizedName(SakuraMain.MODID + "." + name);
    this.attackDamage = 3.0F + material.getAttackDamage();
    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;
        }
    });
}
 
Example #8
Source File: ItemLevitationOrb.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ItemLevitationOrb() {
	super("levitation_orb");
	this.setMaxDamage(60);
	this.setMaxStackSize(1);

	this.addPropertyOverride(new ResourceLocation("fill"), new IItemPropertyGetter() {
		@SideOnly(Side.CLIENT)
		public float apply(@Nonnull ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
			return 1 - (float) stack.getItemDamage() / (float) stack.getMaxDamage();
		}
	});
}
 
Example #9
Source File: ItemOrb.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ItemOrb() {
	super("orb", "glass_orb", "mana_orb");

	this.addPropertyOverride(new ResourceLocation("fill"), new IItemPropertyGetter() {
		@SideOnly(Side.CLIENT)
		public float apply(@Nonnull ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
			double mana = ManaManager.getMana(stack);
			double maxMana = ManaManager.getMaxMana(stack);

			return (int) (10 * mana / maxMana) / 10f;
		}
	});
}
 
Example #10
Source File: ItemMobHarness.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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;
        }
    });
}
 
Example #11
Source File: ItemDolly.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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;
        }
    });
}
 
Example #12
Source File: ItemPetContract.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void addItemOverrides()
{
    this.addPropertyOverride(new ResourceLocation(Reference.MOD_ID, "signed"), new IItemPropertyGetter()
    {
        @Override
        public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn)
        {
            return ItemPetContract.this.isSigned(stack) ? 1.0F : 0.0F;
        }
    });
}