Beispiel #1
0
  /** Called when a player right clicks an entity with an item. */
  public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving) {
    if (par2EntityLiving instanceof EntityPig) {
      EntityPig entitypig = (EntityPig) par2EntityLiving;

      if (!entitypig.getSaddled() && !entitypig.isChild()) {
        entitypig.setSaddled(true);
        --par1ItemStack.stackSize;
      }

      return true;
    } else {
      return false;
    }
  }
  /** Returns true if the item can be used on the given entity, e.g. shears on sheep. */
  public boolean itemInteractionForEntity(
      ItemStack stack, EntityPlayer playerIn, EntityLivingBase target) {
    if (target instanceof EntityPig) {
      EntityPig var4 = (EntityPig) target;

      if (!var4.getSaddled() && !var4.isChild()) {
        var4.setSaddled(true);
        var4.worldObj.playSoundAtEntity(var4, "mob.horse.leather", 0.5F, 1.0F);
        --stack.stackSize;
      }

      return true;
    } else {
      return false;
    }
  }