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; }
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; } }); }
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); }
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; } }); }
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(); } }); }
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; } }); }
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; } }); }
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; } }); }
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; } }); }
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; } }); }
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; } }); }
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; } }); }
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); } }); }
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; } }); }
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); } }); }
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; } }); }
@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; } }); }
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; } }); }
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; } } }); }
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; } }); }
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; } }); }
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; } } }); }
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; } }); }
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; } }); }
@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; } }); }
@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; } }); }
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; } }); }
@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")); } }